Networking and Internet Modules
ipaddress
Represents IPv4 and IPv6 addresses, networks and interfaces. Network membership and prefix lengths can be checked without DNS or network access. Strict network parsing rejects host bits; address classification is not a substitute for an access policy.
Formal Syntax & Structure
python syntaxpython
import ipaddressReturn Value
module
Module namespace available through import; import is a statement, not a value-returning expression.
Working Example
Example Snippetpython
from ipaddress import ip_network, ip_addressnetwork = ip_network("192.0.2.0/24")print(ip_address("192.0.2.7") in network)