How to validate ipaddress in python
We can use the Python module "IP" for validating ipaddresses. A fully configured Python script for validating ipaddress is given below.
#!/usr/bin/python
from IPy import IP
ip = raw_input("Enter the ip:")
length = ip.split('.')
if len(length) == 4:
try:
IP('{}'.format(ip))
print "Entered ipaddress is valid"
except:
print "Entered ipaddress is invalid"
else:
print "Entered ipaddress is invalid"
Hopes that this will be helpful...