如何像这样转换列表:
94.192.0.0/14
94.0.0.0/12
93.96.0.0/16
至:
94.192.0.0-94.195.255.255
94.0.0.0-94.15.255.255
93.96.0.0-93.96.255.255
使用python3吗?
使用ipaddress
内置模块:
>>> import ipaddress
>>> net=ipaddress.ip_network('94.192.0.0/14')
IPv4Network('94.192.0.0/14')
>>> '%s-%s' % (net[0], net[-1])
'94.192.0.0-94.195.255.255'
使用,for i in net
您还可以枚举网络中的所有IP地址net
。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句