World's Best AI Learning Platform with profoundly Demanding Certification Programs
Designed by IITian's, only for AI Learners.
Download our e-book of Introduction To Python
4 (4,001 Ratings)
218 Learners
Neha Kumawat
5 months ago
print (ipaddress.ip_address(u'192.168.0.255'))
print (ipaddress.ip_address(u'192.168.0.256'))
192.168.0.255
ValueError: u'192.168.0.256' does not appear to be an IPv4 or IPv6 address
print (ipaddress.ip_address(u'FFFF:9999:2:FDE:257:0:2FAE:112D'))
#invalid IPV6 address
print (ipaddress.ip_address(u'FFFF:10000:2:FDE:257:0:2FAE:112D'))
ffff:9999:2:fde:257:0:2fae:112d
ValueError: u'FFFF:10000:2:FDE:257:0:2FAE:112D' does not appear to be an IPv4 or IPv6 address
print type(ipaddress.ip_address(u'192.168.0.255'))
print type(ipaddress.ip_address(u'2001:db8::'))
print ipaddress.ip_address(u'192.168.0.255').reverse_pointer
print ipaddress.ip_network(u'192.168.0.0/28')
255.0.168.192.in-addr.arpa
192.168.0.0/28
print (ipaddress.IPv4Address(u'192.168.0.2') > ipaddress.IPv4Address(u'192.168.0.1'))
print (ipaddress.IPv4Address(u'192.168.0.2') == ipaddress.IPv4Address(u'192.168.0.1'))
print (ipaddress.IPv4Address(u'192.168.0.2') != ipaddress.IPv4Address(u'192.168.0.1'))
True
False
True
print (ipaddress.IPv4Address(u'192.168.0.2')+1)
print (ipaddress.IPv4Address(u'192.168.0.253')-3)
# Increases the previous octet by value 1.
print (ipaddress.IPv4Address(u'192.168.10.253')+3)
# Throws Value error
print (ipaddress.IPv4Address(u'255.255.255.255')+1)
192.168.0.3
192.168.0.250
192.168.11.0
AddressValueError: 4294967296 (>= 2**32) is not permitted as an IPv4 address