📜  python ip地址增量 - Python代码示例

📅  最后修改于: 2022-03-11 14:46:34.896000             🧑  作者: Mango

代码示例1
# Import module
import ipaddress
 
# Arithmetic Operation on IPv4 address
print(ipaddress.IPv4Address(u'129.117.0.0')-6)
print (ipaddress.IPv4Address(u'175.199.42.211')+55)
print (ipaddress.IPv4Address(u'0.0.0.0')-1)
print (ipaddress.IPv4Address(u'255.255.255.255')+1)
 
# Arithmetic Operation on IPv6 address
print (ipaddress.IPv6Address(u'2001:0db8:85a3:2bfe:070d:8a2e:0370:7334')-330)
print (ipaddress.IPv6Address(u'2001:0db8:85a3:2bfe:070d:8a2e:0370:7334')+1000)
print (ipaddress.IPv6Address(u'0000::0000')-1)
print (ipaddress.IPv6Address(u'ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff')+1)