Converting Hex to decimal

Peter Hansen peter at
Tue Jun 1 15:47:34 CEST 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?


More information about the Python-list mailing list