Converting hex to char help

Ognjen Bezanov ognjen at mailshack.com
Sun May 14 14:33:56 EDT 2006


Hi all, I am trying to convert a hexdecimal value to a char using this code:

print ' %c ' % int(0x62)

this works fine, but if I want to do this:

number = "62"
print ' %c ' % int("0x" + number)

I get an error:

Traceback (most recent call last):
  File "<stdin>",line 1, in ?
ValueError: invalid literal for in(): 0x62

How can I convert a string "0x62" to int/hex without this problem?

Thanks!
 




More information about the Python-list mailing list