时间:2021-07-01 10:21:17 帮助过:91人阅读
这里实现将子网掩码长度转换为具体的子网掩码地址:
def exchange_maskint(mask_int): bin_arr = ['0' for i in range(32)] for i in range(mask_int): bin_arr[i] = '1' tmpmask = [''.join(bin_arr[i * 8:i * 8 + 8]) for i in range(4)] tmpmask = [str(int(tmpstr, 2)) for tmpstr in tmpmask] return '.'.join(tmpmask) if __name__ == '__main__': print exchange_maskint(24)
更多Python简单实现子网掩码转换的方法介绍相关文章请关注PHP中文网!