报错:SyntaxError: Non-ASCII character '\xe4' in file
SyntaxError: Non-ASCII character '\xe1' in file recommendation.py on line 1, but no encoding declared; see http://python.org/dev/peps/pep-0263/ for details
原因:注释里面出现了中文,而 Python 支持的 ASCII 码无中文。
在ython官网得到如下帮助信息:
Python will default to ASCII as standard encoding if no other encoding hints are given.
翻译:如果没有其他编码提示,Python将默认为ASCII作为标准编码。
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
翻译:要定义源代码编码,必须在源文件中第一行或第二行放置一个魔术注释。
解决办法:
在头文件中添加如下代码:
# -*- coding: utf-8 -*-
报错:SyntaxError: Non-ASCII character '\xe4' in file的更多相关文章
- SyntaxError: Non-ASCII character '\xe4' in file t.py on line 3, but no encoding declared
问题 报错代码 #!/usr/bin/python s = "你好" print s 执行报错: File "t.py", line 3 SyntaxError ...
- [已解决]关于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 , but no encod ...
- 关于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 ...
- 前端控制台 JavaScript函数报错 SyntaxError: expected expression, got ';' SyntaxError: expected expression, got 'if'
在火狐浏览器下调试时, 页面报错SyntaxError: expected expression, got ';'或者SyntaxError: expected expression, got 'if ...
- JavaScript函数报错SyntaxError: expected expression, got ';'
故事背景:编写Javaweb项目,在火狐浏览器下运行时firebug报错SyntaxError: expected expression, got ';'或者SyntaxError: expected ...
- Xamarin 示例Standard Controls报错:xamarin Failed to compile interface file. See Build Output for details
Standard Controls 示例下载地址: http://developer.xamarin.com/content/StandardControls/ Xamarin官网上的IOS示例“St ...
- 解决FPDF报错:FPDF error: Not a JPEG file / FPDF error: Not a PNG file
最近有个项目需要用到FPDF,但是输出的时候报错: FPDF error: Not a JPEG file: http://***/data/attachment/forum/201603/19/10 ...
- 解决Undefined symbols for architecture x86_64: 报错 和 ld: warning: ld: warning: ignoring file警告
出现这种错误的情况: 用iphone5模拟器编译程序正常, 用iphone5s以上的模拟器编译出现Undefined symbols for architecture x86_64: 报错 和 ld: ...
- Linux下Oracle11G RAC报错:在安装oracle软件时报file not found一例
Linux下Oracle11G RAC报错:在安装oracle软件时报file notfound一例 1.现象 之前安装一切都比較顺利,安装oracle软件时,进度到30%时报错:file not f ...
- TP连接数据库报错:SQLSTATE[HY000] [2002] No such file or directory
连接数据库报错:“SQLSTATE[HY000] [2002] No such file or directory”. 出现这个问题的原因是PDO无法找到mysql.sock或者mysqld.soc ...
随机推荐
- Myeclipse学习总结(5)——Myeclipse常用快捷键再学习
Ctrl+1 快速修复 Ctrl+D: 删除当前行 Ctrl+Q 定位到最后编辑的地方 Ctrl+L 定位在某行 Ctrl+O 快速显示 OutLine Ctrl+T 快速显示当前类的继承结构 ...
- selenium+java解决富文本输入
方法一: Actions actions = new Actions(driver); actions.sendKeys(Keys.TAB).perform(); //鼠标通过tab要先移到富文本框中 ...
- Elasticsearch---基于scroll技术滚动搜索大量数据
如果一次性要查出来比如10万条数据,那么性能会很差,此时一般会采取用scoll滚动查询,一批一批的查,直到所有数据都查询完处理完 使用scoll滚动搜索,可以先搜索一批数据,然后下次再搜索一批数据,以 ...
- IOS写一个能够支持全屏的WebView
这样来写布局 一个TitleView作为顶部搜索栏: @implementation TitleView - (id)initWithFrame:(CGRect)frame { self = [sup ...
- idea 中web项目 用自带tomcat启动问题,
严重: Exception sending context initialized event to listener instance of class com.zenointel.logserve ...
- ThinkPHP5+Redis单例型购物车
<?php /** * Redis + 单例型购物车 * param $basket 存储商品信息 * param $ins 存储实例化对象 */ namespace lib; use redi ...
- Response.Redirect(),Server.Transfer(),Server.Execute()的区别与网站优化
转 http://blog.csdn.net/dannywj1371/article/details/10213631 1.Response.Redirect():Response.Redirect方 ...
- 最简单的启动并连接一个redis的docker容器
启动一个容器: $ sudo docker run --name <name> -d redis 连接一个容器: sudo docker run -it --link <name&g ...
- 前端学习笔记-CSS
- vue强制绑定css3的缩放效果transfrom:scale()
vue不提供 transfrom:scale(1.5) : 会报错 ,错误是 "TypeError: _vm.scale is not a function": 原因:Vue将其 ...