Reputation: 25
What is the right way of reading my hexstring = '40040000' by "little endian" way in python. The result I am expecting is 440h.
Upvotes: 2
Views: 923
Reputation: 151067
Not sure what format you want the result to be in. You could use struct
and binascii
together to convert it to an int.
>>> struct.unpack('<L', binascii.unhexlify('40040000'))
(1088,)
Which is the same as 440h:
>>> hex(struct.unpack('<L', binascii.unhexlify('40040000'))[0])
'0x440'
Upvotes: 2