Trouble converting hex to decimal?

Steve Holden steve at holdenweb.com
Sat Feb 5 09:03:44 EST 2005


Earl Eiland wrote:

> I'm trying to process the IP packet length field, as recorded by pcap
> (Ethereal) and recovered using pcapy.  When I slice out those bytes, I
> get a value that shows in '\x00' format, rather than '0x00'.  Neither
> int() nor eval() are working.  How do I handle this?
> 
> Earl Eiland
> 

You could either reconstruct the value yourself from the ord() values of 
the individual bytes, or look at the struct module which can help you 
with this kind of decoding task.

regards
  Steve
-- 
Meet the Python developers and your c.l.py favorites March 23-25
Come to PyCon DC 2005                      http://www.pycon.org/
Steve Holden                           http://www.holdenweb.com/



More information about the Python-list mailing list