SyntaxError: Non-ASCII character '\xe8' in file
来源:互联网 发布:java电信项目 编辑:程序博客网 时间:2024/06/05 05:36
用Python进行编程,运行时出现如下错误
SyntaxError: Non-ASCII character '\xe8' in file
查了下Python的默认编码文件是用的ASCII码
只要在文件开头加入#-*- coding: UTF-8 -*-或者#coding=utf-8就可以了
参考:
Defining the Encoding
Python will default to ASCII as standard encoding if no other encoding hints are given. To define a source code encoding, a magic comment must be placed into the source files either as first or second line in the file, such as: # coding=<encoding name> or (using formats recognized by popular editors) #!/usr/bin/python # -*- coding: <encoding name> -*- or #!/usr/bin/python # vim: set fileencoding=<encoding name> : More precisely, the first or second line must match the regular expression "coding[:=]\s*([-\w.]+)". The first group of this expression is then interpreted as encoding name. If the encoding is unknown to Python, an error is raised during compilation. There must not be any Python statement on the line that contains the encoding declaration. To aid with platforms such as Windows, which add Unicode BOM marks to the beginning of Unicode files, the UTF-8 signature '\xef\xbb\xbf' will be interpreted as 'utf-8' encoding as well (even if no magic encoding comment is given). If a source file uses both the UTF-8 BOM mark signature and a magic encoding comment, the only allowed encoding for the comment is 'utf-8'. Any other encoding will cause an error.
0 0
- SyntaxError: Non-ASCII character '\xe8' in file
- SyntaxError- Non-ASCII character '-xe8' in file
- SyntaxError: Non-ASCII character '\xe8' in file
- python SyntaxError: Non-ASCII character '\xe8' in file
- Phthon出现SyntaxError: Non-ASCII character '\xe8' in file
- Non-ASCII character '\xe8' in file
- File "xxx.py", line 8 SyntaxError: Non-ASCII character '\xe8' in file xxx.py
- Python中文问题 或 SyntaxError: Non-ASCII character '\xe8' in file
- SyntaxError: Non-ASCII character '\xe8' in file,but no encoding decleared
- Python保存时提示“SyntaxError: Non-ASCII character '\xe8' in file”
- Python保存时提示“SyntaxError: Non-ASCII character '\xe8' in file”
- python SyntaxError: Non-ASCII character '\xe8' in file (2013-04-13 21:53:14)
- python执行报错:SyntaxError: Non-ASCII character '\xe8' in file .
- SyntaxError: Non-ASCII character '\xe4' in file
- SyntaxError: Non-ASCII character '\xe6' in file
- SyntaxError: Non-ASCII character '\xb2' in file
- SyntaxError: Non-ASCII character '\xe4' in file
- SyntaxError: Non-ASCII character '\xe7' in file
- IP选项初识
- 安卓面试题系列-3
- (Apache服务)修改服务可执行路径
- Java中的反射
- Struts2学习笔记(十一)命名空间
- SyntaxError: Non-ASCII character '\xe8' in file
- 学会这几个.你就能成为bat脚本小子了...(转来看看的)
- hdu 1800 - Flying to the Mars
- 2812:信息分割
- 安卓面试题系列-4
- 2015年腾讯暑期实习面试
- 禁止网页内容复制、另存为、粘贴的简单方案
- Swing做一个类似红绿灯的东西
- qml+QZXing实现实时QRCode识别和给重复造轮子的一些建议