🌐
Python
docs.python.org β€Ί 3 β€Ί library β€Ί struct.html
struct β€” Interpret bytes as packed binary data
Python object serialization. Two main applications for the struct module exist, data interchange between Python and C code within an application or another application compiled using the same compiler (native formats), and data interchange between applications using agreed upon data layout (standard formats).
🌐
GeeksforGeeks
geeksforgeeks.org β€Ί python β€Ί struct-module-python
struct module in Python - GeeksforGeeks
May 10, 2025 - The struct module in Python allows you to work with binary data by providing functionality to convert between Python values and C-style binary data. This is particularly useful when dealing with binary file formats or network protocols.
Discussions

What is struct in Python terms?
Both struct and class in C++ define a user-defined type. They only differ by implicit inheritance and access to members (public and private). More on reddit.com
🌐 r/cpp_questions
14
6
May 14, 2020
Using a Python 'class' as a C-style 'struct'
What you want is a dataclass , which will do exactly this. You will need to use type hints to declare your attributes. from dataclasses import dataclass @dataclass class DataStructure: data_member_one: int = 0 data_member_two: int = 0 ... settings = DataStructure(data_member_one=10, data_member_two=20) # or set them manually: settings.data_member_two = 25 Note, as I've shown, Python style for variables and attributes is lower_case_with_underscore. More on reddit.com
🌐 r/learnpython
8
2
March 22, 2023
Can someone please ELI5 me struct module?
It basically packs your data into C-style structures. Python has a lot of metadata associated with objects. Even for a number like 3, there's a lot of other information that represents its state. Lower level languages, like C, just store data in its most basic format in memory and leave controlling said memory to the programmer. For example, in Python, the number 100 is stored as something like "value of type [int] referenced [5] times, contains [100]", and in C, it's just "01100100" - the number in binary. The struct module lets you convert things back and forth between Python's internal representation and those "raw" bytes. More on reddit.com
🌐 r/learnpython
6
2
September 29, 2013
Struct Unpack in Python
Without knowing what format your "datum attribute" is (I assume you mean date?), and in what format it was packed, we can't really provide you with a direction or solution. I'm assuming you understand what unpacking does? Have you checked the number of bytes you're dealing with? Which bytes are used to represent what? If you're certain all that is correct, make sure you are using the right endianness, or that you're not using signed numbers when they should be unsigned or vice versa. More on reddit.com
🌐 r/learnpython
3
1
January 15, 2024
🌐
Beautiful Soup
tedboy.github.io β€Ί python_stdlib β€Ί generated β€Ί struct.html
struct β€” Python Standard Library
Functions to convert between Python values and C structs represented as Python strings.
🌐
Python Module of the Week
pymotw.com β€Ί 2 β€Ί struct
struct – Working with Binary Data - Python Module of the Week
There are a set of module-level functions for working with structured values, and there is also the Struct class (new in Python 2.5). Format specifiers are converted from their string format to a compiled representation, similar to the way regular expressions are.
🌐
W3Schools
w3schools.com β€Ί python β€Ί ref_module_struct.asp
Python struct Module
The struct module converts between Python values and C structs represented as Python bytes objects.
🌐
GitHub
github.com β€Ί andreax79 β€Ί python-cstruct
GitHub - andreax79/python-cstruct: C-style structs for Python Β· GitHub
Convert C struct/union definitions into Python classes with methods for serializing/deserializing.
Author: andreax79
🌐
Jython
jython.org β€Ί jython-old-sites β€Ί docs β€Ί library β€Ί struct.html
7.3. struct β€” Interpret strings as packed binary data β€” Jython v2.5.2 documentation
This module performs conversions between Python values and C structs represented as Python strings. It uses format strings (explained below) as compact descriptions of the lay-out of the C structs and the intended conversion to/from Python values.
Find elsewhere
🌐
Educative
educative.io β€Ί answers β€Ί what-is-the-python-struct-module
What is the Python struct module?
The struct module in Python is used to convert native Python data types such as strings and numbers into a string of bytes and vice versa.
🌐
PhoenixNAP
phoenixnap.com β€Ί home β€Ί kb β€Ί devops and development β€Ί how to use python struct functions
How to Use Python Struct Functions | phoenixNAP KB
December 16, 2025 - Data transfer between Python and C applications. Structs require constructing a format string for packing and unpacking data.
🌐
Scaler
scaler.com β€Ί home β€Ί topics β€Ί struct in python
Struct in Python| Scaler Topics
December 12, 2022 - The struct in Python is used to perform the conversion of the C struct (which is represented as a Python byte object) into a Python string of bytes and vice versa. The struct in Python is used for file handling in the case of binary-stored data.
🌐
DigitalOcean
digitalocean.com β€Ί community β€Ί tutorials β€Ί python-struct-pack-unpack
Python struct.pack and struct.unpack for Binary Data | DigitalOcean
March 20, 2026 - Python Struct Pack Unpack with format strings, byte order, pack_into and unpack_from, plus C interop examples. Learn with runnable code.
🌐
AskPython
askpython.com β€Ί python-modules β€Ί python-struct-module
Python struct Module - AskPython
January 21, 2020 - The Python struct module is used to provide a simple Pythonic interface to access and manipulate C’s structure datatype.
🌐
Snarky
snarky.ca β€Ί proposing-a-struct-syntax
Proposing a struct syntax for Python
June 8, 2023 - I want to introduce the new (soft) keyword struct (the name was chosen by my wife, Andrea, as more understandable than data once you explain struct is short for structure and how it's used in other programming languages). You would be able to follow the keyword with the name of the struct class.
🌐
Readthedocs
python-cstruct.readthedocs.io
Python CStruct documentation
Convert C struct/union definitions into Python classes with methods for serializing/deserializing.
🌐
PyPI
pypi.org β€Ί project β€Ί cstruct
Python-CStruct
Convert C struct/union definitions into Python classes with methods for serializing/deserializing.
🌐
pytz
pythonhosted.org β€Ί nstruct
namedstruct 1.0.0 documentation
The common usage of namedstruct is to create type definitions with interfaces like namedstruct.nstruct and namedstruct.enum, use namedstruct.typedef.parse() or namedstruct.typedef.create() interfaces on the created types to parse a packed struct bytes to a Python object, use namedstruct.typedef.new() (or directly namedstruct.typedef.__call__() of the created type, like normal Python classes) to create new objects of the defined type, and use namedstruct.NamedStruct._tobytes() to convert objects to packed bytes.
🌐
Python
docs.python.org β€Ί 3.0 β€Ί library β€Ί struct.html
struct β€” Interpret bytes as packed binary data β€” Python v3.0.1 documentation
This module performs conversions between Python values and C structs represented as Python bytes objects. It uses format strings (explained below) as compact descriptions of the lay-out of the C structs and the intended conversion to/from Python values.