I'm trying to convert a ushort to bytes. However, when I try this:
>>import struct
>>val =struct.pack('<H',10000)
b"\x10'"
Instead of:
b'\x10\x27'
Is this a bug? Or I am just doing something silly?
I'll be writing this data to a serial device.
Thanks in advance.
It's an alternate representation for
\x27
:You won't have any problems converting back to the int representation: