Thursday, 15 September 2011

hex - How do I convert a hexadecimal to a string in Python? -



hex - How do I convert a hexadecimal to a string in Python? -

using python,

h = 0x11012 # ... ??? result = '11012'

what intermediary steps have take go h -> result?

python 2.7 , later:

>>> "{:x}".format(0x11012) '11012'

python 2.6:

>>> "{0:x}".format(0x11012) '11012'

python 2.5 , earlier:

>>> "%x" % 0x11012 '11012'

python hex

No comments:

Post a Comment