ipaddress.v4_int_to_packed
Prev: ipaddress.summarize_address_range | Up: ipaddress | Next: ipaddress.v6_int_to_packed
Rel: ipaddress.AddressValueError, ipaddress.collapse_addresses, ipaddress.get_mixed_type_key, ipaddress.ip_address
Ref: docs.python.org — ipaddress.v4_int_to_packed
Tags: #public #python3 #stdlib #ipaddress
Import
import ipaddress
from ipaddress import v4_int_to_packed
Signature & Overview
ipaddress.v4_int_to_packed(address)
Represent an address as 4 packed bytes in network (big-endian) order.
Usage
import ipaddress
assert ipaddress.v4_int_to_packed(0x7F000001) == b"\x7f\x00\x00\x01"
Gotchas
- Converts a 32-bit
intto 4 big-endian bytes (raisesValueErrorif out of range).
REPL Inspect
from ipaddress import v4_int_to_packed
help(v4_int_to_packed)
Linked from
Related notes
- tuts/python3/stdlib_module/ipaddress/summarize_address_range Linked here; links to this page; shared tags: #ipaddress, #stdlib
- tuts/python3/stdlib_module/ipaddress/v6_int_to_packed Linked here; links to this page; shared tags: #ipaddress, #stdlib
- tuts/python3/stdlib_module/ipaddress Linked here; links to this page; shared tags: #stdlib
- tuts/python3/stdlib_module/ipaddress/AddressValueError Linked here; shared tags: #ipaddress, #stdlib
- tuts/python3/stdlib_module/ipaddress/collapse_addresses Linked here; shared tags: #ipaddress, #stdlib
- tuts/python3/stdlib_module/ipaddress/get_mixed_type_key Linked here; shared tags: #ipaddress, #stdlib
- tuts/python3/stdlib_module/ipaddress/ip_address Linked here; shared tags: #ipaddress, #stdlib
- tuts/python3/stdlib_module/ipaddress/ip_interface shared tags: #ipaddress, #stdlib
- tuts/python3/stdlib_module/ipaddress/ip_network shared tags: #ipaddress, #stdlib
- tuts/python3/stdlib_module/ipaddress/IPv4Address shared tags: #ipaddress, #stdlib