[英]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 അ
. print a
给出\അ
作为输出,但我想打印它代表的unicode字符,即അ
。 How can I achieve this? 我怎样才能做到这一点?
The \\u\u003c/code> escape is not meaningful inside a non-unicode string.
\\u\u003c/code>转义在非unicode字符串中没有意义。
You need to do
a = u'\അ'
. 你需要做
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')
如果你说你从其他地方获取字符串并且需要解释其中的unicode转义,那么请
print a.decode('unicode-escape')
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.