python脚本执行报错:SyntaxError: Non-ASCII character '\xe6' in file ip.py on line 4...
2017-09-01 11:32
3687 查看
报错信息
所以我们就要指定字符编码:养成良好习惯很重要.
[root@chenbj ~]# python ip.py 192.168.1.1 File "ip.py", line 4 SyntaxError: Non-ASCII character '\xe6' in file ip.py on line 4, but no encoding declared; see http://www.python.org/peps/pep-0263.html for details 翻译: SyntaxError:第4行文件ip.py中的非ASCII字符“\ xe6”,但未声明编码; 有关详细信息,请参阅http://www.python.org/peps/pep-0263.html
所以我们就要指定字符编码:养成良好习惯很重要.
[root@chenbj ~]# cat ip.py #!/usr/bin/env python # _*_ coding:utf-8 _*_
_*_ coding:utf-8 _*_ 是用来指定文件编码为utf-8的
相关文章推荐
- 关于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。
- Python: SyntaxError: Non-ASCII character '\xa3' in file main.py on line 3, but no encoding declared
- 运行python程序时出现错误“SyntaxError: Non-ASCII character '\xe8' in file variable.py on line 1, but no encod”
- [已解决]关于python无法显示中文的问题:SyntaxError: Non-ASCII character '\xe4' in file test.py on line 3, but no encoding declared。
- 【python问题系列--1】SyntaxError:Non-ASCII character '\xe5' in file kNN.py on line 2, but no encoding declared;
- python出现中文错误:SyntaxError: Non-ASCII character '\xe7' in file car-training.py on line 7, but no encod
- 关于python无法显示中文的问题:SyntaxError: Non-ASCII character '\xe4' in file test.py on line 3, but no encoding
- python错误:SyntaxError: Non-UTF-8 code starting with '\xcb' in file E:/Python/test.py on line 2
- 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
- [已解决]关于python无法显示中文的问题:SyntaxError: Non-ASCII character '\xe4' in file test.py on line 3, but no enc
- 关于python无法显示中文的问题:SyntaxError: Non-ASCII character '\xe4' in file test.py on line 3
- 关于python无法显示中文的问题:SyntaxError: Non-ASCII character '\xe4' in file test.py on line 3, but no encoding
- 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
- 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
- python问题Non-ASCII character '\xe5' in file Apriori.py on line 1, but no encoding declared 解决办法
- SyntaxError: Non-ASCII character '\xe5' in file D:/pcode/xx.py on line 21, but no encoding declared
- python出现SyntaxError: Non-ASCII character '\xe6' in file 打印日期.py on line 1, but no encoding declared;
- python问题Non-ASCII character '\xe5' in file Apriori.py on line 1, but no encoding declared 解决办法
- File "message.py", line 2 SyntaxError: Non-UTF-8 code starting with '\xbd' in file message.py on l