Help needed: Printing unicode characters in user defined format

"Martin v. Löwis" martin at
Thu Oct 21 20:57:19 CEST 2004

Pekka Niiranen wrote:
> I need to loop thru characters in Unicode string
> and store each character in format \U+hhhh, where
> hhhh is the value of unicode character in hexadecimal?

"".join(['\\U+%.4x' % ord(c) for c in unistr])


More information about the Python-list mailing list