Q67: How does the 'struct' module parse binary data byte streams?

The struct module converts between Python values and C struct binary representations using format strings (e.g. 'i' for 4-byte int, 'f' for float, 'h' for short int). Key functions: struct.pack() and struct.unpack().

Key Takeaways
  • Packs/unpacks C-compatible binary data structures.
  • Essential for parsing binary network protocols and byte files.
Knowledge Check

Which function converts Python primitives into packed C-style binary byte streams?