简体   繁体   中英

How to print a variable that contains a unicode character?

print u'\u0D05'
a = '\u0D05'
print a

print a gives \അ as output but I want to print the unicode character it represents, which is . How can I achieve this?

The \\u\u003c/code> escape is not meaningful inside a non-unicode string. You need to do a = u'\അ' .

If you're saying you're getting the string from somewhere else and need to interpret unicode escapes in it, then do print a.decode('unicode-escape')

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM