Getting unicode escape sequence from unicode character?

K

Kenneth McDonald

Given a Python unicode character (string of length one), how would I
find out the \uXXXX escape sequence for it? This isn't obvious from the
docs I've been looking through.

Thanks,
Ken
 
C

Carl Banks

Kenneth said:
Given a Python unicode character (string of length one), how would I
find out the \uXXXX escape sequence for it? This isn't obvious from the
docs I've been looking through.

You can use the ord builtin, or the encode method with
"unicode_escape":
'\\u1234'


Carl Banks
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,042
Latest member
icassiem

Latest Threads

Top