[Tutor] hexadecimal to decimal

Alan Gauld alan.gauld at blueyonder.co.uk
Fri Mar 12 20:20:06 EST 2004


> >>> print int('0xe7')
> Traceback (most recent call last):
>   File "<stdin>", line 1, in ?
> ValueError: invalid literal for int(): 0xe7
> >>>
> 
> ko.
> what's the trick?

Add the base at the end:

print int('0xe7',16)  # 16 is base


HTH,

Alan G.



More information about the Tutor mailing list