August 2018
Intermediate to advanced
366 pages
10h 14m
English
The struct.pack and struct.unpack functions support many options and formatters to define what data should be written/read and how it should be written/read.
The most common formatters for byte order are the following:
| Character | Byte order |
|---|---|
| = | native |
| < | little-endian |
| > | big-endian |
If none of those is specified, the data will be encoded in your system native byte order and will be aligned as it's naturally aligned in your system memory. It's strongly discouraged to save data this way as the only system guaranteed to be able to read it back is the one that saved it.
For the data itself, each type of data is represented by a single character, and each character defines the kind of data (integer, float, string) and ...