IP子网掩码格式转换

def exchange_maskint(mask_int):
bin_arr = ['' for i in range(32)]
for i in range(mask_int):
bin_arr[i] = ''
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)
exchange_mask = lambda mask: sum(bin(int(i)).count('') \
for i in mask.split('.')) print(exchange_mask('255.255.0.0'))
上一篇:10最好用的Node.js工具、插件和资料库


下一篇:操作Frame和IFrame中页面元素