struct — Interpret bytes as packed binary data — Python 3.16.0a0 documentation

docs.python.org

Tin mới

Binary Data Services

codecs — Codec registry and base classes

Python Module Index

3.16.0a0 Documentation

The Python Standard Library

Functions and Exceptions¶

This module converts between Python values and C structs represented as Python bytes objects. Compact format strings describe the intended conversions to/from Python values. The module’s functions and objects can be used

Functions and Exceptions¶

This module converts between Python values and C structs represented as Python bytes objects. Compact format strings describe the intended conversions to/from Python values. The module’s functions and objects can be used

Byte Order, Size, and Alignment¶

By default, C types are represented in the machine’s native format and byte order, and properly aligned by skipping pad bytes if necessary (according to the rules used by the C compiler). This behavior is chosen so that

array: Space efficient arrays of uniformly typed numeric values.

The array and ctypes modules, as well as third-party modules like numpy, use similar – but slightly different – type codes.

DeprecationWarning

Changed in version 3.1: Previously, some of the integer formats wrapped out-of-range values and raised DeprecationWarning instead of struct.error.

json: Encode and decode the JSON format.

pickle: Convert Python objects to streams of bytes and back.