Fixed width integer types (e.g. uint32) in Python

后端 未结 2 1269
执念已碎
执念已碎 2021-01-21 19:49

Certain mathematical operations, especially on data read from hardware drivers, can depend on fixed width of the data type. Example: bitwise shift. What is the Pythonic way of c

2条回答
  •  感情败类
    2021-01-21 20:27

    For interfacing with hardware we normally use the struct standard library - specifically struct.pack and struct.unpack not only are fixed widths handled but also endianess issues. See the python 2 or python 3 library manuals.

提交回复
热议问题