Converting Hex to decimal

fishboy fishboy at spamspamspam.com
Tue Jun 1 15:02:32 EDT 2004


On 1 Jun 2004 01:51:23 -0700, deanl at redstone.co.uk (dean) wrote:

>Hello group:
>
>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?
>
>Also, is there an oracle module available for windows xp and hp-ux?
>
>Much appreciated 
>
>dean
> 
>please reply to diabolik(nospam)@uku.co.uk remove (nospam)


The hex data in file is a bit confusing.  I can think of two ways you
could mean this.

For the one that is a file with text that reads like:

2344
fabd
3343
43ae
fe34

Hmm, how's about int()?  It accepts a radix.

>>> int('aefdcba',16)
183491770
>>> int('11',16)
17

The other way would be with struct/array like others have mentioned.

><{{{*>




More information about the Python-list mailing list