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的更多相关文章

  1. 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 ...

  2. [已解决]关于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 ...

  3. 关于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 ...

  4. 前端控制台 JavaScript函数报错 SyntaxError: expected expression, got ';' SyntaxError: expected expression, got 'if'

    在火狐浏览器下调试时, 页面报错SyntaxError: expected expression, got ';'或者SyntaxError: expected expression, got 'if ...

  5. JavaScript函数报错SyntaxError: expected expression, got ';'

    故事背景:编写Javaweb项目,在火狐浏览器下运行时firebug报错SyntaxError: expected expression, got ';'或者SyntaxError: expected ...

  6. 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 ...

  7. 解决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 ...

  8. 解决Undefined symbols for architecture x86_64: 报错 和 ld: warning: ld: warning: ignoring file警告

    出现这种错误的情况: 用iphone5模拟器编译程序正常, 用iphone5s以上的模拟器编译出现Undefined symbols for architecture x86_64: 报错 和 ld: ...

  9. Linux下Oracle11G RAC报错:在安装oracle软件时报file not found一例

    Linux下Oracle11G RAC报错:在安装oracle软件时报file notfound一例 1.现象 之前安装一切都比較顺利,安装oracle软件时,进度到30%时报错:file not f ...

  10. TP连接数据库报错:SQLSTATE[HY000] [2002] No such file or directory

     连接数据库报错:“SQLSTATE[HY000] [2002] No such file or directory”. 出现这个问题的原因是PDO无法找到mysql.sock或者mysqld.soc ...

随机推荐

  1. PHP学习总结(8)——PHP入门篇之WAMPServer集成环境安装和配置

    WampServer就是Windows Apache Mysql PHP集成安装环境,即在window下的apache.php和mysql的服务器软件.WampServer是一款由法国人开发的Apac ...

  2. MySQL 存储

    1.存储过程简介 我们常用的操作数据库语言SQL语句在执行的时候需要要先编译,然后执行,而存储过程(Stored Procedure)是一组为了完成特定功能的SQL语句集,经编译后存储在数据库中,用户 ...

  3. static final常量变量的正确书写规范

    AccountConstants.java类 命名:常量类以Constants单词命名结尾 package com.paic.pacz.core.salesmanage.util; import ja ...

  4. 树莓派 rtl8188eu 芯片wifi驱动

    总算是找到了.现拿出来分享.參考地址:https://www.raspberrypi.org/forums/viewtopic.php? p=462982#p462982 下载的地址是:https:/ ...

  5. 学习笔记一:关于directx sdk的安装于一些概念

    关于directx sdk开发环境的安装: 在百度搜索了directx sdk,进入了微软的官网,下载了DXSDK_Jun10.exe 百度网盘:http://pan.baidu.com/s/1o6r ...

  6. 使用ClassLoader类装载器获取系统资源

    使用ClassLoader类装载器获取系统资源 2010-05-11 16:19:39 分类: Java /* ClassLoader 有两种方法获得系统资源,一个种静态方法,一种是实例方法. 静态方 ...

  7. 2015.05.05,外语,读书笔记-《Word Power Made Easy》 15 “如何谈论事情进展” SESSION 42

    HOW TO TALK ABOUT WHAT GOES ON TEASER PREVIEW 一些以-ate结束的动词,通常表示: to exhaust([ig'zɔ:st] n. 排气,排气装置 v. ...

  8. Redis通过命令行进行配置

    redis 127.0.0.1:6379[1]> config set requirepass my_redis OK redis 127.0.0.1:6379[1]> config ge ...

  9. Ubuntu 16.04 安装 Wireshark分析tcpdump的pcap包——sudo apt install wireshark-qt

    tcpdump 的抓包保存到文件的命令参数是-w xxx.cap   抓eth1的包  tcpdump -i eth1 -w /tmp/xxx.cap    抓 192.168.1.123的包  tc ...

  10. eclipse 配置 tomcat 时候的一些注意事项(随机更新)

    1,一些常用的设置,如下图,不特别说明了,看标记应该就知道注意事项了 2,配置文件的问题.eclipse里面如下图的配置文件里如果有所改动,那么在eclipse里启动Tomcat的时候,Tomcat的 ...