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 in Python? Like in C:
uint32_t number=100;
array[0]=(number >>24) & 0xff;
array[1]=(number >>16) & 0xff;
array[2]=(number >>8) & 0xff;
array[3]=number & 0xff;
Can someone show me how? It is strange to me at first to program without types.
Sven has you answer. However, byte shifting numbers (as in your question) is also possible in Python: