Converting Hex to decimal

Peter Hansen peter at engcorp.com
Tue Jun 1 09:47:34 EDT 2004


dean wrote:

> I have a file containing hex data. 

What does the term "hex data" mean to you?  Does it mean
binary?  Does it mean that there are only characters in
the range 0-9A-F and that each pair of characters represents
a single byte?  Something else?  It is not a term with a
precisely defined meaning.

> I would like to convert the
> contents of the file to decimal by reading each by sequentially (one
> byte at the time). Is there a module that has such functionality or
> does someone have the relevant code?

Definitely Python can do it, possibly with the struct module,
but it all depends on what "hex data" means.  Do you have
an example of what input will translate to what output?

-Peter



More information about the Python-list mailing list