int() should be extended?

sismex01 at hebmex.com sismex01 at hebmex.com
Mon Oct 21 11:55:10 EDT 2002


> From: Xiao-Qin Xia [mailto:xx758 at cam.ac.uk]
> 
> Dear gustavo,
> 
> Thanks for you reply, but my system displays different result:
> """
> >>> s = "0x41"
> >>> int(s[2:])
> 41
> """
> That seems reasonable, but not what I want, I need 65 instead of 41.
> 
> Cheers,
> Xiao-Qin Xia
> 
> 

ahahahaha! :-)

My mistake, add a second argument to int(), indicating the base
of the number you wish to translate:

int("41", 16) == 65

heh heh, too quick for my own good. :-)

good luck :-)

-gustavo




More information about the Python-list mailing list