Python2.7修改默认编码utf-8
2019-07-04 本文已影响0人
yangqing
CentOS系统的python环境修改默认编码为utf-8
vim /usr/lib/python2.7/site-packages/sitecustomize.py
# sitecustomize.py
# this file can be anywhere in your Python path,
# but it usually goes in ${pythondir}/lib/site-packages/
import sys
sys.setdefaultencoding('utf-8')
编写Python脚本声明编码
vim test.py
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# name: test.py
print('Hello Python!')