How to convert a string to hex?

Remco Gerlich scarblac-spamtrap at pino.selwerd.nl
Thu Jun 29 09:16:21 EDT 2000


Jens Arnfelt wrote in comp.lang.python:
> Is there any easy way to go the other way, like convert hex number
> "0x26100511FFFF" to a string with the the following value: "26100511FFFF"
> ?

x = 0x26100     # (your example is too large for my computer)

y = "0x%x" % x  # String formatting "%x" formatter makes hex numbers

y is now "0x26100".

-- 
Remco Gerlich,  scarblac at pino.selwerd.nl
  3:13pm  up 115 days,  3:26,  5 users,  load average: 0.52, 0.52, 0.48



More information about the Python-list mailing list