码迷,mamicode.com
首页 > 其他好文 > 详细

pycharm 输出中文出现\x*乱码

时间:2017-07-06 18:44:12      阅读:146      评论:0      收藏:0      [点我收藏+]

标签:put   har   class   output   string   ring   decode   str   span   

\x*为中文字符:使用decode对其进行编码,再输出即可

 1 s = 你好
 2 print s
 3 # output:你好
 4 
 5 s = [你好]
 6 print s
 7 # output:[‘\xe4\xbd\xa0\xe5\xa5\xbd‘]
 8 
 9 s = [你好]
10 print str(s[0]).decode(string_escape)
11 # output:你好

 

pycharm 输出中文出现\x*乱码

标签:put   har   class   output   string   ring   decode   str   span   

原文地址:http://www.cnblogs.com/sunruina2/p/7127415.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!