Hexadecimal bytes to integers
gbreed at cix.compulink.co.uk
gbreed at cix.compulink.co.uk
Thu Mar 14 09:07:56 EST 2002
More information about the Python-list mailing list
Thu Mar 14 09:07:56 EST 2002
- Previous message (by thread): Hexadecimal bytes to integers
- Next message (by thread): does Python support some kind of "casting"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
pekka niiranen wrote: > How can I convert messages below to list of bytes: > > message = 0x01040000000271 > or > message = 0104000000A271 > to > m = [0,1,0,4,0,0,0,0,0,0,0,0,'A',2,7,1] You're showing nybbles, not bytes. For bytes, [int(message[i:i+2], 16) for i in range(2, len(message),2)] or [int(message[i:i+2], 16) for i in range(0, len(message),2)]
- Previous message (by thread): Hexadecimal bytes to integers
- Next message (by thread): does Python support some kind of "casting"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list