python默认编码设置
2015-04-27 19:41
260 查看
打开python 的gui,输入
查询系统当前默认编码
默认情况下显示编码方式为ASCII
在python安装目录下的Lib/site-packages文件夹下新建sitecustomize.py,内容为
重启python,再次检查编码方式,发现已经改为utf8
sitecustomize.py is a special script; Python will try to import it on startup, so any code in it will be run automatically. As the comment mentions, it can go anywhere (as long as import can find it), but it usually goes in the site-packages directory within your Python lib directory.
setdefaultencoding function sets, well, the default encoding. This is the encoding scheme that Python will try to use whenever it needs to auto-coerce a unicode string into a regular string.
/article/4868217.html
http://blog.chinaunix.net/uid-22183602-id-2973101.html
默认情况下显示编码方式为ASCII
在python安装目录下的Lib/site-packages文件夹下新建sitecustomize.py,内容为
sitecustomize.py is a special script; Python will try to import it on startup, so any code in it will be run automatically. As the comment mentions, it can go anywhere (as long as import can find it), but it usually goes in the site-packages directory within your Python lib directory.
setdefaultencoding function sets, well, the default encoding. This is the encoding scheme that Python will try to use whenever it needs to auto-coerce a unicode string into a regular string.
参考:
https://docs.python.org/2/library/site.html/article/4868217.html
http://blog.chinaunix.net/uid-22183602-id-2973101.html
相关文章推荐
- Python 设置系统默认编码(常见问题汇总)
- Python设置系统默认编码
- python默认编码与解码格式设置
- Python设置默认编码
- Python 设置系统默认编码以及其他编码问题大全
- Python 设置系统默认编码以及其他编码问题大全
- python 默认编码的理解与设置
- Python设置默认编码为UTF-8
- PYTHON设置默认语言编码
- 设置python的默认编码为utf8
- 设置python的默认编码为utf8
- python----设置默认编码
- Python设置默认编码为utf8的方法
- python2设置系统默认编码为utf-8
- Python 设置系统默认编码
- Python 设置系统默认编码
- Python 设置系统默认编码
- PYTHON设置默认语言编码
- 设置python的默认编码为utf8
- Python 设置系统默认编码