[Tutor] Covert numbers to hex fails

Tom Tucker tktucker at gmail.com
Wed May 25 04:56:34 CEST 2005


Good evening!  I am trying to pass a number variable and have it
converted to hex.  Any recommendations on how to achieve this?  Thank
you.

FAILS
----------
>>> value = 1234567890
>>> hexoutput = hex('%d' % (value))
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
TypeError: hex() argument can't be converted to hex
>>> 



WORKS
-------------
>>> hexoutput = hex(1234567890)
>>> print hexoutput
0x499602d2
>>>


More information about the Tutor mailing list