[Tutor] Struct the solution for Hex translation
johan at accesstel.co.za
Mon Feb 19 15:19:28 CET 2007
I read in some conversations that the struct module maybe helpful in
converting Hex values to binary or decimal. Maybe I understood it
Here is my problem.
I have a 22 byte data packet on a tcp socket connection. My data field is
from the 6th byte to byte 20. 14 bytes in total.
The first two bytes of the data is a 16 bit value. Eg: "\xe2\x01'
I can the first byte into binary if I use 'e2', but I don't know how to get
the '\x' out of the first byte to use it in python. My data has the '\x' and
all I need is the 'e2'.
Any advice of the usage of the struct module or how I can get rid of the
'\x' in my data?
Hopefully I have given enough information.
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.5.441 / Virus Database: 268.18.2/692 - Release Date: 2007/02/18
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Tutor