Python 2x 中list 里面的中文打印效果乱码
生活随笔
收集整理的這篇文章主要介紹了
Python 2x 中list 里面的中文打印效果乱码
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
事情是這樣的 本來是處理python2x 中list 里面的中文打印為unicode? 想處理下打印為中文,處理之后打印的效果中文亂碼了代碼如下
#!/usr/bin/python
# -*- coding: utf-8 -*-
import sys
reload(sys)
sys.setdefaultencoding("utf-8")list_a = ["中國", "num"]
print (list_a)
case_list_righ = str(list_a).decode('string_escape')
print case_list_righ
print ("".join(list_a))
看下打印的效果
這個問題自己測處理方法
點擊File -setting -File? Encoding? 修改project encoding 方式為uft-8
具體位置如下
vigia之后在次運行看下打印的果果
?
總結
以上是生活随笔為你收集整理的Python 2x 中list 里面的中文打印效果乱码的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Ubuntu 系统 Pycharm中无
- 下一篇: python 2x list 里面的中文