String 如何制作'\u';python3中的工作变量

String 如何制作'\u';python3中的工作变量,string,python-3.x,unicode,byte,String,Python 3.x,Unicode,Byte,我从网络上得到一个字符串,如: s='\u0070\u0079\u0074\u0068\u006f\u006e'或其他 当我打印时 它输出'\u0070\u0079\u0074\u0068\u006f\u006e' 我想让“\u”工作 当我打印时 它输出“python”(u'\u0070\u0079\u0074\u0068\u006f\u006e'=python) 我该怎么办?我不知道我是否明白你的意思,但如果你的意思是想将带有尾随斜杠的unicode字符转换为真正的unicode字符,你可以使

我从网络上得到一个字符串,如:
s='\u0070\u0079\u0074\u0068\u006f\u006e'或其他
当我打印时
它输出'\u0070\u0079\u0074\u0068\u006f\u006e'
我想让“\u”工作
当我打印时
它输出“python”(u'\u0070\u0079\u0074\u0068\u006f\u006e'=python)

我该怎么办?

我不知道我是否明白你的意思,但如果你的意思是想将带有尾随斜杠的unicode字符转换为真正的unicode字符,你可以使用

对于python2:
print s.decode('unicode-escape')

对于python3:
print(字节,'ascii')。decode('unicode-escape'))