unicode positions of characters
Martin v. Löwis
martin at v.loewis.de
Thu Jan 16 09:47:35 EST 2003
Giorgi Lekishvili <gleki at gol.ge> writes:
> Could somebody tell me how can I get the unicode hexadecimals of chars?
> e.g., 'char' --> xyzv
I thought I understood the question, but then your example breaks this
understanding. What has the identifier xyzv to do with the string
literal 'char'? Where is anything hexadecimal, or unicode, in this
example?
To get the Unicode ordinal from a Unicode character, use the ord
function. To get a hexadecimal representation of a number, use the hex
function.
>>> s=u"Hello"
>>> ord(s[0])
72
>>> hex(ord(s[0]))
'0x48'
Regards,
Martin
More information about the Python-list
mailing list