[Python-Dev] (no subject)
Arcane
arcane at deepfort.com
Mon Jun 21 09:17:43 EDT 2004
François Pinard wrote:
>[Patrick Stinson]
>
>
>
>>if you had a hex string like '0x7c' how would you convert it to an
>>int? int(0x7c) works, but not int('0x7c')
>>
>>
>
>This kind of question is better discussed on the `python' list than the
>`python-dev' list.
>
>You may try int('0x7c', 16) if you know the base, or int(`0x7c', 0) if
>you do not. The doc-string for `int' does not hint at using 0 as a base
>when it has to be guessed, maybe this is an oversight? The Library
>Reference Manual says all about it, however! :-)
>
>
>
int(eval('0x7c'))
Marc
More information about the Python-list
mailing list