[Tutor] hexadecimal to decimal
Philippe Strauss
philippe.strauss at practeo.ch
Thu Mar 11 04:46:46 EST 2004
Dear Python Tutor :^)
I need to convert some number represented by hexadecimal STRINGS
to decimal integers (then strings again, btw).
Python 2.2.1 (#1, Apr 21 2002, 08:38:44)
[GCC 2.95.4 20011002 (Debian prerelease)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> print int(0xe7)
231
ok.
>>> print int(0x00)
0
ok.
>>> print int('1')
1
ok.
>>> print int('0xe7')
Traceback (most recent call last):
File "<stdin>", line 1, in ?
ValueError: invalid literal for int(): 0xe7
>>>
ko.
what's the trick?
thanks in advance.
More information about the Tutor
mailing list