Python Struct Module
Binary data packing — pack, unpack, calcsize, pack_into. This category documents 5 Python struct module entries, and each page gives you the full syntax, the parameter list, the return value, and a runnable example. The entries include: struct.pack(), struct.unpack(), struct.calcsize(), struct.pack_into(), struct.unpack_from(). struct.pack() packs values into a bytes object according to a format string. struct.unpack() unpacks bytes into values according to a format string. struct.calcsize() returns the size of the struct (and bytes needed) for the given format. struct.pack_into() packs values into a buffer (bytearray) at the given offset. struct.unpack_from() unpacks bytes from a buffer starting at offset. For a structured walkthrough of the whole topic, read the Struct Module guide. Struct Module belongs to the Modules & Metadata group alongside Importlib Module, Pkgutil Module, Compileall Module, Zipapp Module. You can also search across every category from the search page, browse the complete A–Z index, or try any example in the Python playground.