来源:https://pypi.python.org/pypi/IPy
IPy模块
该模块可以方便的处理IPv4和IPv6地址。
以下是从来源中拷贝的一些例子:
>>> from IPy import IP
>>> ip = IP(‘127.0.0.0/30‘)
>>> for x in ip:
... print(x)
...
127.0.0.0
127.0.0.1
127.0.0.2
127.0.0.3
>>> ip2 = IP(‘0x7f000000/30‘)
>>> ip == ip2
1
>>> ip.reverseNames()
[‘0.0.0.127.in-addr.arpa.‘, ‘1.0.0.127.in-addr.arpa.‘, ‘2.0.0.127.in-addr.arpa.‘, ‘3.0.0.127.in-addr.arpa.‘]
>>> ip.reverseName()
‘0-3.0.0.127.in-addr.arpa.‘
>>> ip.iptype()
‘PRIVATE‘
时间: 2024-10-07 00:23:18