I'm attempting to convert a list of numbers into a list of byte objects of length 1 for use with struct.pack_into
. However, much to my surprise, I appear to be getting n
0s in each byte object:
>>> [bytes(n) for n in [1,2,3]]
[b'\x00', b'\x00\x00', b'\x00\x00\x00']
I was expecting:
[b'\x01', b'\x02', b'\x03']
How can I get the latter?