About 7,410,000 results
Open links in new tab
  1. struct - C-like structures in Python - Stack Overflow

    Aug 30, 2008 · cstruct2py is a pure python library for generate python classes from C code and use them to pack and unpack data. The library can parse C headres (structs, unions, enums, …

  2. binary - Python struct.pack and unpack - Stack Overflow

    Oct 14, 2020 · 15 struct.pack takes non-byte values (e.g. integers, strings, etc.) and converts them to bytes. And conversely, struct.unpack takes bytes and converts them to their 'higher …

  3. python - Reading a binary file into a struct - Stack Overflow

    The idiomatic way to do this in Python is use the struct module and call struct.unpack() in a loop—either a fixed number of times if you know the number of them in advance, or until end …

  4. python - How to pack and unpack using ctypes (Structure <-> str ...

    If I use struct to define a binary structure, the struct has 2 symmetrical methods for serialization and deserialization (pack and unpack) but it seems ctypes doesn't have a straightforward way …

  5. python - convert bytes or bytearray to struct - Stack Overflow

    May 16, 2023 · 3 Two ways: one using ctypes and one using struct: For ctypes, I simplified the structure but it has the same layout for 32-bit signed integers and an unsigned byte. It works …

  6. python - How to read packed structures using ctypes - Stack …

    Is there a way in python to unpack C structures created using #pragma pack(x) or __attribute__((packed)) using structs? Alternatively, how to determine the manner in which …

  7. python - How to switch byte order of binary data - Stack Overflow

    Dec 13, 2012 · struct.error: bad char in struct format How can I unpack these values with the correct byte ordering? Am I stuck reading in the two bytes separately then reassembling them …

  8. python - Extract the fields of a C struct - Stack Overflow

    Sep 21, 2012 · Most typically this involves writing Python code with the struct or ctypes modules. So I'll have a .h file full of struct definitions, and I have to manually read through them and …

  9. Python: Similar functionality in struct and array vs ctypes

    Aug 27, 2018 · Fundamentally, struct, array and ctypes do different things. struct deals with converting Python values into binary in-memory formats. array deals with efficiently storing a …

  10. struct - Fastest way to pack a list of floats into bytes in python ...

    Mar 30, 2012 · This is good, but it's worth noting the ' * ' operator seems inefficient, it is needlessly convting floatlist into a tuple before passing it to struct.pack. Is there a way to pack from an …