I am working my way through bytes in python and I have to say I have come across numerous difficulties. One of them is int.tobytes()
function. Converting integers up to 32 works fine, but after that the output has single characters that I don't understand. For example:
x=90
y=33
z=76
print(x.to_bytes(4, 'big'))
print(y.to_bytes(4, 'big'))
print(z.to_bytes(4, 'big'))
Output:
b'\x00\x00\x00Z'
b'\x00\x00\x00!'
b'\x00\x00\x00L'
I don't understand the single digit byte at the start. For example, I would expect 90 to be:
'\x00\x00\x00\x5A'
(Converting it to hexadecimal), but instead I get results like this. I can't seem to find solutions online. What do these single characters represent? Thanks