代码如下:
#-*- coding:utf-8 -*-
import sys
reload(sys)
sys.setdefaultencoding('utf-8')
为什么已经写了#-*- coding:utf-8 -*-
下面还要sys.setdefaultencoding('utf-8')
求教?谢谢
已解决
这里说的挺明白的:也谈 Python 的中文编码处理
巴扎黑2017-04-17 16:37:59
The above one refers to the encoding of this file. The root python sys has nothing to do with it.
黄舟2017-04-17 16:37:59
You can import sys in python. Then use sys.getdefaultencoding() to see what the default encoding of your python is. Anyway, my default is ascii...
By the way, I used the lines of your code on Ubuntu yesterday, and the Chinese output to the command line is still garbled... slightly Weird... In the end, I processed Chinese directly in the file