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!')
网友评论