ID EN
Socket

inet_pton

Python 3.11

Convert an IP address from its family-specific string format to a packed, binary format. inet_pton() is useful when a library or network protocol calls for an object of type in_addr (similar to inet_aton()) or in6_addr.

Syntax

PYTHON
socket.inet_pton(address_family, ip_string)

See Also

inet_pton() inet_aton() AF_INET AF_INET6 OSError Availability