About 51 results
Open links in new tab
  1. binary - Python struct.pack and unpack - Stack Overflow

    Oct 14, 2020 · 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-order' equivalents.

  2. packing and unpacking variable length array/string using the struct ...

    The struct module does only support fixed-length structures. For variable-length strings, your options are either: Dynamically construct your format string (a str will have to be converted to a bytes before …

  3. What exactly does Python's struct.pack do? - Stack Overflow

    The return value of this is a bytestring (in Python 3), or a standard (non-unicode) string in Python 2, showing 0x01D1F23A represented as an unsigned long in little-endian byte order.

  4. Creating packet using struct.pack with python - Stack Overflow

    Feb 18, 2013 · Creating packet using struct.pack with python Asked 12 years, 11 months ago Modified 12 years, 11 months ago Viewed 16k times

  5. Understanding Python's struct pack/unpack functions

    Oct 28, 2020 · I am working on project which includes usage of struct module and its pack/unpack functions with python3.6 I have referred to many articles like this one and have got the basic idea but …

  6. python - How can I pack a string in struct.pack - Stack Overflow

    In the format string ("<1s") you're passing to struct.pack, the 1 denotes the maximum number of characters that field can store. (See the paragraph beginning "For the 's'..." in the struct …

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

    This might be a silly question but I couldn't find a good answer in the docs or anywhere. If I use struct to define a binary structure, the struct has 2 symmetrical methods for serialization and

  8. Fastest way to pack a list of floats into bytes in python

    Mar 30, 2012 · I have a list of say 100k floats and I want to convert it into a bytes buffer. buf = bytes() for val in floatList: buf += struct.pack('f', val) return buf This is quite slow. How can I make it ...

  9. Python-bytes () vs struct.pack () - Stack Overflow

    They do two different things; compare bytes(1234) with struct.pack("!H", 1234). The first just provides a 4-byte string representation of the number bytes object with 1,234 null bytes; the second provides a …

  10. How to pack a struct in a struct using python struct?

    Mar 2, 2017 · There doesn't seem to be builtin way to pack structs into structs, but you can do it manually. You pack the first struct into binary data, then pack that binary data into the second struct …