On this page
socket.inet_ntop
Prev: socket.inet_ntoa | Up: socket | Next: socket.inet_pton
Rel: socket.AddressFamily, socket.close, socket.create_connection, socket.create_server
Ref: docs.python.org — socket.inet_ntop
Tags: #public #python3 #stdlib #socket
Import
import socket
from socket import inet_ntop
Signature & Overview
socket.inet_ntop(af, packed_ip) -> string formatted IP address
Convert a packed IP address of the given family to string format.
Usage
import socket
assert socket.inet_ntop(socket.AF_INET, b"\x0a\x00\x00\x01") == "10.0.0.1"
assert socket.inet_ntop(socket.AF_INET6, b"\x00" * 15 + b"\x01") == "::1"
Gotchas
- Supports both IPv4 (
AF_INET, 4 bytes) and IPv6 (AF_INET6, 16 bytes).
REPL Inspect
from socket import inet_ntop
help(inet_ntop)
Linked from
Related notes
- tuts/python3/stdlib_module/socket/inet_ntoa Linked here; links to this page; shared tags: #socket, #stdlib
- tuts/python3/stdlib_module/socket/inet_pton Linked here; links to this page; shared tags: #socket, #stdlib
- tuts/python3/stdlib_module/socket/AddressFamily Linked here; shared tags: #socket, #stdlib
- tuts/python3/stdlib_module/socket/close Linked here; shared tags: #socket, #stdlib
- tuts/python3/stdlib_module/socket/create_connection Linked here; shared tags: #socket, #stdlib
- tuts/python3/stdlib_module/socket/create_server Linked here; shared tags: #socket, #stdlib
- tuts/python3/stdlib_module/socket/socket Linked here; shared tags: #socket, #stdlib
- tuts/python3/stdlib_module/socket links to this page; shared tags: #stdlib
- tuts/python3/stdlib_module/socket/dup shared tags: #socket, #stdlib
- tuts/python3/stdlib_module/socket/error shared tags: #socket, #stdlib