python代码中常见的问题【持续更新中。。。】

SyntaxError: Non-ASCII character '\xe8' in file log.py on line 9, but no encoding declared; see http://www.python.org/peps/pep-0263.html for details

文件头添加: # -- coding: utf-8 --

 

UnicodeDecodeError: 'ascii' codec can't decode byte 0xe5 in position 0: ordinal not in range(128)

文件头引入:

import sys

reload(sys)

sys.setdefaultencoding('utf8')

 

你可能感兴趣的:(python)