Aug-30-2020, 10:16 PM
(Aug-28-2020, 11:11 AM)Gribouillis Wrote: The bytes type is already an array of integers in the range(0, 256).
>>> x = b'B\xda\xed\xc5' >>> list(x) [66, 218, 237, 197]For the conversion to 32 bits integer, you could have a look into the struct module
>>> import struct >>> x = b'B\xda\xed\xc5' >>> struct.unpack('i', x) (-974267838,) >>> struct.unpack('<i', x) (-974267838,) >>> struct.unpack('>i', x) (1121643973,)
Thanks Gribouillis, I have changed the code a little to get unsigned values.
temp = struct.unpack('I', byte)
print(temp)
I am not getting the value's expected.
Is this because of LSB and / or MSB.
I don't understand how to implement in the unpack function.
Thanks,