I need to send a message of bytes in Python and I need to convert an unsigned integer number to a byte array. How do you convert an integer value to an array of four bytes i
This is kind of an old thread, but in Python 3.2+ now you can simply say:
number = 100 number.to_bytes(4, byteorder = 'big')
or byteorder = 'little' as per your needs. Documentation here.
byteorder = 'little'