Converting hex string to an integer

Alexandre Fayolle alf at merlin.fayauffre.org
Thu Aug 26 04:32:09 EDT 2004


Le 26-08-2004, Derek Fountain <nospam at example.com> a écrit :
> Given the character string "0x00A1B2C3" arriving at sys.argv[1] how do I 
> convert that to an integer which I can do some math on?

>>> s = "0x00A1B2C3"
>>> int(s, 16)
10597059
  

-- 
Alexandre Fayolle                              LOGILAB, Paris (France).
http://www.logilab.com   http://www.logilab.fr  http://www.logilab.org



More information about the Python-list mailing list