A C struct
can be packed into flat binary data, which is what Python 2 calls a string. The struct
module lets you take a string that represents one of these C structs, and “unpack” it into a Python data structure.
To do so you call struct.unpack
. You need to specify a format string (as defined in the linked docs), and it returns a tuple of values unpacked from the data.
solved basic python syntax [closed]