On this page
socket.inet_ntoa
Prev: socket.inet_aton | Up: socket | Next: socket.inet_ntop
Rel: socket.AddressFamily, socket.close, socket.create_connection, socket.create_server
Ref: docs.python.org — socket.inet_ntoa
Tags: #public #python3 #stdlib #socket
Import
import socket
from socket import inet_ntoa
Signature & Overview
socket.inet_ntoa(packed_ip, /)
Convert an IP address from 32-bit packed binary format to string format.
Usage
import socket
assert socket.inet_ntoa(b"\x7f\x00\x00\x01") == "127.0.0.1"
Gotchas
- IPv4-only (exactly 4 bytes): Prefer
inet_ntop()oripaddress.ip_address(raw)for IPv4 + IPv6.
REPL Inspect
from socket import inet_ntoa
help(inet_ntoa)
Linked from
Related notes
- tuts/python3/stdlib_module/socket/inet_aton Linked here; links to this page; shared tags: #socket, #stdlib
- tuts/python3/stdlib_module/socket/inet_ntop 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