(这部分转自南瓜小米粥的博客):
这是Python的编码问题,设置python的默认编码为utf8
python安装目录:/etc/python2.x/sitecustomize.py
1 |
import sys
|
2 |
reload (sys)
|
3 |
sys.setdefaultencoding( 'utf-8' )
|
4 |
try :
|
5 |
import apport_python_hook
|
6 |
except ImportError:
|
7 |
pass
|
8 |
else :
|
9 |
apport_python_hook.install()
|
1 |
import sys
|
2 |
sys.setdefaultencoding( 'utf-8' ) #set default encoding to utf-8
|
1 |
>>> import sys
|
2 |
>>> |
3 |
'utf-8' |
1 |
print s.encode( 'utf-8' )
|