1.报错提示信息
SyntaxError: Non-ASCII character '\xe4' in file 02languageElement.py on line 3, but no encoding declared; see http://python.org/dev/peps/pep-0263/ for details
2.报错原因
python默认编码格式是ASCII ,不能识别中文。
3.解决方案
在.py文件从第一行开始添加如下能识别中文的utf8编码,随后保存文件重新执行就不会报错了。
- 方案1
# This Python file uses the following encoding: utf-8
import os, sys
- 方案2
#!/usr/bin/python
# -*- coding: utf-8 -*-
import os, sys
- 方案3
#!/usr/local/bin/python
# coding: utf-8
import os, sys