ipaddress.ip_address()
ipaddress.ip_address() is a Python function in the IP Address Module category. Creates an IPv4Address or IPv6Address object from a string. The syntax is ipaddress.ip_address(address). Returns: IPv4Address or IPv6Address. A typical example: import ipaddress
addr = ipaddress.ip_address("192.168.1.1")
addr.version # 4
addr.is_private # True
addr.is_loopback # False. A close sibling is ipaddress.ip_network(), which creates an IPv4Network or IPv6Network object from an IP network string. A close sibling is ipaddress.ip_interface(), which creates an IPv4Interface or IPv6Interface (host with network). A close sibling is IPv4Address.is_private, which returns True if the address is in a private IP range. A close sibling is IPv4Address.is_loopback, which returns True if the address is a loopback address (127.0.0.0/8). More about this category: IP address handling — IPv4Address, IPv6Address, IPv4Network, IPv6Network. Related IP Address Module entries: ipaddress.ip_network(), ipaddress.ip_interface(), IPv4Address.is_private, IPv4Address.is_loopback, IPv4Address.is_multicast, IPv4Address.is_global. This page is part of the free Python Reference documentation covering 978+ functions, methods, and modules with examples and parameter details.