Converting Hex to decimal

Miki Tebeka miki.tebeka at
Tue Jun 1 12:50:30 CEST 2004

Hello Dean,

> I have a file containing hex data. 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?
Have a look at `array' or `struct' modules.
If you just want to read "raw" bytes you can do:
for c in open("some_file").read():
    print hex(ord(c))
(Note that this read *all* the file into memory)

Miki Tebeka <miki.tebeka at>
The only difference between children and adults is the price of the toys.

More information about the Python-list mailing list