Don’t parse it. Just ask.
import socket
try:
socket.inet_aton(addr)
# legal
except socket.error:
# Not legal
More Related Contents:
- How can I check if an ip is in a network in Python?
- Get IP address of visitors using Flask for Python
- What is the quickest way to HTTP GET in Python?
- How can I get the IP address from a NIC (network interface controller) in Python?
- Basic Python client socket example
- How do I get Flask to run on port 80?
- Multiple ping script in Python
- Validation of a Password – Python
- Python socket receive – incoming packets always have a different size
- How to know if urllib.urlretrieve succeeds?
- Validating with an XML schema in Python
- Test if an internet connection is present in python
- Discovering public IP programmatically
- Sending a reset in TCP/IP Socket connection
- In python, how to check if a date is valid?
- Obtain MAC Address from Devices using Python
- Order of Serializer Validation in Django REST Framework
- Using explicit (predefined) validation set for grid search with sklearn
- How to get Network Interface Card names in Python?
- Get local network interface addresses using only proc?
- List of IP addresses/hostnames from local network in Python
- How do I determine all of my IP addresses when I have multiple NICs?
- How to make a field conditionally optional in WTForms?
- Unwanted RST TCP packet with Scapy
- Why is host aborting connection?
- Validating user input strings in Python
- Validating a yaml document in python
- Requests with multiple connections
- How to programmatically enable/disable network interfaces? (Windows XP)
- Python: check whether a network interface is up