python问题Non-ASCII character '\xe5' in file Apriori.py on line 1, but no encoding declared 解决办法
2016-08-03 10:32
861 查看
python中出现Non-ASCII character '\xe7' in file ex6.py on line 1, but no encoding declare的错误
可按照错误建议网址查看http://www.python.org/peps/pep-0263.html
发现是因为Python在默认状态下不支持源文件中的编码所致。解决方案有如下三种:
一、在文件头部添加如下注释码:
# coding=<encoding name> 例如,可添加# coding=utf-8
二、在文件头部添加如下两行注释码:
#!/usr/bin/python
# -*- coding: <encoding name> -*- 例如,可添加# -*- coding: utf-8 -*-
三、在文件头部添加如下两行注释码:
#!/usr/bin/python
# vim: set fileencoding=<encoding name> : 例如,可添加# vim: set fileencoding=utf-8 :
可按照错误建议网址查看http://www.python.org/peps/pep-0263.html
发现是因为Python在默认状态下不支持源文件中的编码所致。解决方案有如下三种:
一、在文件头部添加如下注释码:
# coding=<encoding name> 例如,可添加# coding=utf-8
二、在文件头部添加如下两行注释码:
#!/usr/bin/python
# -*- coding: <encoding name> -*- 例如,可添加# -*- coding: utf-8 -*-
三、在文件头部添加如下两行注释码:
#!/usr/bin/python
# vim: set fileencoding=<encoding name> : 例如,可添加# vim: set fileencoding=utf-8 :
相关文章推荐
- python问题Non-ASCII character '\xe5' in file Apriori.py on line 1, but no encoding declared 解决办法
- python问题Non-ASCII character '\xe5' in file Apriori.py on line 1, but no encoding declared 解决办法
- [已解决]关于python无法显示中文的问题:SyntaxError: Non-ASCII character '\xe4' in file test.py on line 3, but no encoding declared。
- [已解决]关于python无法显示中文的问题:SyntaxError: Non-ASCII character '\xe4' in file test.py on line 3, but no enc
- Python: SyntaxError: Non-ASCII character '\xa3' in file main.py on line 3, but no encoding declared
- 关于python无法显示中文的问题:SyntaxError: Non-ASCII character '\xe4' in file test.py on line 3, but no encoding
- 关于python无法显示中文的问题:SyntaxError: Non-ASCII character '\xe4' in file test.py on line 3, but no encoding
- 【python问题系列--1】SyntaxError:Non-ASCII character '\xe5' in file kNN.py on line 2, but no encoding declared;
- 关于python无法显示中文的问题:SyntaxError: Non-ASCII character '\xe4' in file test.py on line 3, but no encoding
- python - 中文打印报错SyntaxError: Non-ASCII character '\xe4' in file test.py on line 3, but no encoding declared。
- SyntaxError: Non-ASCII character '\xe5' in file index.py on line 6, but no encoding declared; see http://python.org/dev/peps/pep-0263/ for details
- SyntaxError: Non-UTF-8 code starting with '\xc5' in file t.py on line 3,but no encoding declared;see http://python.org/dev/peps/pep-0263/ for details
- SyntaxError: Non-ASCII character '\xe5' in file a.py on line 9, but no encoding declared; see http://www.python.org/peps/pep-0263.html for details
- python出现SyntaxError: Non-ASCII character '\xe6' in file 打印日期.py on line 1, but no encoding declared
- SyntaxError: Non-ASCII character '\xe4' in file test.py on line 3, but no encoding declared。
- SyntaxError: Non-ASCII character '***' in file *** on line **,but no encoding declared;
- Non-ASCII character '\xe8' in file xxx.py on line 8, but no encoding declared
- Non-ASCII character '\xe8' in file xxx.py on line 8, but no encoding declared
- python出现SyntaxError: Non-ASCII character '\xe6' in file 打印日期.py on line 1, but no encoding declared;
- SyntaxError: Non-ASCII character '\xe8' in file model.py on line 300, but no encoding declared; 报错