According to the documentation, specifying the byte order removes any padding:
No padding is added when using non-native size and alignment, e.g. with ‘<’, ‘>’, ‘=’, and ‘!’.
Therefore, assuming you require little endian packing, the following gives the required output:
>>> struct.pack('<Hf', id1, i)
'\x01\x00\x18\x1c\x14?'
Note the <. (3f can be encoded as ASCII ?, hence the replacement)
Alastair McCormack
- 28k
- 8
- 81
- 106