python 将字符串中的unicode字符码转换成字符

将字符串str =’\u98ce\u534e\u7684\u51b2\u950b'转换成汉字显示

可以直接print输出

print u'\u98ce\u534e\u7684\u51b2\u950b'

但是这样在处理json文件中的编码就比较麻烦,可以将整串字符串转化:

    s = str.encode('latin-1').decode('unicode_escape')

 

posted @ 2018-07-19 21:31  Michealjobs  阅读(2680)  评论(0编辑  收藏  举报