This is when we convert numbers to bytes :
print(int.to_bytes(65, length=1, byteorder='big')) #this converts numbers to characters
result:
A
why do i see the same result even if i used different byteorder ?
print(int.from_bytes(b'A', byteorder='big', signed=True))
print(int.from_bytes(b'A', byteorder='little', signed=True))
result:
65
65
CodePudding user response:
Probably because one char ('A') is stored in a single byte. The change of order big/little is visible with many bytes. Tested with 2 different bytes:
>>> print(int.from_bytes(b'AB', byteorder='big', signed=True))
16706
>>> print(int.from_bytes(b'AB', byteorder='little', signed=True))
16961
See python docs