[Python-Dev] (no subject)

Dan Gass dan.gass at gmail.com
Sat Jun 19 12:15:08 EDT 2004


Patrick,

> if you had a hex string like
> '0x7c'
> how would you convert it to an int?
> 
> int(0x7c) works, but not int('0x7c')

The general python mailing list is a more appropriate place for this
question.  That being said, what you are looking for is
int('0x7c',16).  FYI int('7c',16) also works.  This can be found in
the Python manual (that came with Python) in the Python Library
Reference section 2.1 Built in functions.  You may want to scan
through the tutorial and the library reference material as they both
are good places to look to answer questions like this.

Regards,
Dan Gass



More information about the Python-Dev mailing list