I'm trying to convert an Integer into a 4 byte array with struct.pack(). I'm getting some really odd results though.
import struct
# Using Big Endian Order
struct.pack('>I', 5000) # works fine
>>>'\x00\x00\x13\x88'
struct.pack('>I', 50000) # has a weird "P" variable which the documentation says shouldn't occur with Endian order.
>>>'\x00\x00\xc3P'
Could someone explain what is happening with the 2nd result? I'm expecting an output of 0x0000C350.
Specifically, I'm trying to send this byte array through a socket. e.g.
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect(IP, PORT)
s.send(Message) # I need this message to be Big Endian, Byte array representation of the number.
I'm assigning the result of struct.pack() to Message. The Message is meant to be a 4 byte unsigned integer.