convert binary data to int

Laurent Pointal laurent.pointal at limsi.fr
Wed Jan 10 05:22:53 EST 2007


rubbishemail at web.de a écrit :
> Hello,
> 
> 
> I need to convert a 3 byte binary string like
> "\x41\x00\x00" to 3 int values ( (65,0,0) in this case).
> The string might contain characters not escaped with a \x, like
> "A\x00\x00"
> 
> 
> Any ideas?

>>> s = "\x41\x00\x00"
>>> [ ord(c) for c in s ]
[65, 0, 0]





More information about the Python-list mailing list