This module performs conversions between Python values and C structs represented as Python strings.
-
pack( fmt, v1, v2, ...) - Return a string containing the values v1, v2, ... packed according to the given format. The arguments must match the values required by the format exactly.
unpack( fmt, string) - Unpack the string (presumably packed by pack(fmt, ...)) according to the given format.
calcsize( fmt) - Return the size of the struct (and hence of the string) corresponding to the given format.
pack('hhl', 1, 2, 3) # '\x00\x01\x00\x02\x00\x00\x00\x03'
unpack('hhl', '\x00\x01\x00\x02\x00\x00\x00\x03') # (1, 2, 3)
calcsize('hhl') # 8
index
