使用editplue运行如下程序,出现错误
hex_value1 = 0x13
print("hex_value1的值为:",hex_value1)
SyntaxError: Non-UTF-8 code starting with ‘\xb5‘ in file test.py on line 4, but no encoding declared; see http://python.org/dev/peps/pep-0263/ for details
转载:
Eclipse+PyDev 出现 SyntaxError: Non-UTF-8 code starting with ‘\xb5‘ in file的代码编码问题
SyntaxError: Non-UTF-8 code starting with ‘\xb5‘ in file D:\eclipse-workspace\Pytest1\src\Ptest1\__init__.py on line 3, but no encoding declared; see http://python.org/dev/peps/pep-0263/ for details
原因:
默认情况下,Python 3 源码文件以 UTF-8 编码,所有字符串都是 unicode 字符串。 当然你也可以
两种解决办法:
1、为源码文件指定不同的编码——直接在程序最前面加上如下语句,如gbk:
# coding=gbk
2、修改默认编码格式
在左侧Package Explorer里面找到相应的文件,点击右键选择“Properties”
把编码从默认:
改为:
保存之后再添入中文内容就可以正常运行了。
————————————————
版权声明:本文为CSDN博主「lenka_qin」的原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/oHuandream/article/details/83867736
SyntaxError: Non-UTF-8 code starting with '\xb5' in file test.py on line 4, but no encoding declared; see http://python.org/dev/peps/pep-0263/ for details
原文地址:https://www.cnblogs.com/tangmixun/p/11600887.html