struct module

The Python standard library module that packs values into bytes, and unpacks them, according to a format string.

In more detail

In the format string, B is an unsigned byte, H a two-byte unsigned integer and I a four-byte unsigned integer. A leading ! or > selects big-endian network byte order. The course uses it to show how small a hand-made binary record is compared with JSON.

Example

struct.pack('!BIH', 1, 42, 99)

Related terms

Taught in

References

Certification courses