网络编程-Python的netaddr库

In [1]: from netaddr import *
In [2]: ip = IPAddress('172.16.100.39')
 
ip.format()ip地址的格式化
'172.16.100.39'
 
repr(ip)
"IPAddress('172.16.100.39')"
 
ip = IPNetwork('172.16.100.39/24')
ip.network
IPAddress('172.16.100.0')
 
ip.broadcast
IPAddress('172.16.100.255')
 
ip.ip
IPAddress('172.16.100.39')
 
ip.size
256
 
ip.netmask
IPAddress('255.255.255.0')
 
ip.hostmask
IPAddress('0.0.0.255')
posted @ 2017-12-01 23:40  戴怪兽  阅读(6119)  评论(0编辑  收藏  举报