SyntaxError: Non-UTF-8 code starting with ‘\xc7‘ in file

简介: 学习SyntaxError: Non-UTF-8 code starting with ‘\xc7‘ in file。

解决python编码错误问题

错误原因: 是 xxx.py文件里有中文字符

改正方法:文件的第一行 加上 # coding=gbk

# coding=gbk
# @Time     : 2022/6/7 15:35
# @Author   : hyh
# @File     : test06-1.py
# @Software : PyCharm
name = input("请输入你的姓名:")
print("你的姓名是:%s"%name)
1
2
3
4
5
6
7
8
9



相关文章
|
6天前
|
Python
完美解决丨File “invalid.py“, line 1 print(`Hello World!`) ^ SyntaxError: invalid syntax
完美解决丨File “invalid.py“, line 1 print(`Hello World!`) ^ SyntaxError: invalid syntax
|
6月前
|
XML 编解码 数据格式
python报错 ‘utf-8‘ codec can‘t encode characters in position xxxx-xxxx: surrogates not allowed
python报错 ‘utf-8‘ codec can‘t encode characters in position xxxx-xxxx: surrogates not allowed
184 0
|
10月前
|
Android开发
Failed to obtain GLES 2.x extensions striProcess finished with exit code -1073741819 (0xC0000005)
android studio打开虚拟机时报错信息,解决办法之一(我成功的办法,其他方法试了没用), 打开 设备管理器然后找到你的独显,然后禁用设备,然后再次启动设备就行了,最后再启动你的虚拟机就行了。
88 0
Parse error: syntax error, unexpected '<<' (T_SL) in .../test2.php on line 2
Parse error: syntax error, unexpected '<<' (T_SL) in .../test2.php on line 2
105 0
Dx unsupported class file version 52.0 Conversion to Dalvik format failed with error 1
Dx unsupported class file version 52.0 Conversion to Dalvik format failed with error 1
120 0
error: ac_nonexistent.h: No such file or directory
error: ac_nonexistent.h: No such file or directory
422 0
成功解决 SyntaxError: Non-UTF-8 code starting with \xc0 in file but no encoding declared; see http://p
成功解决 SyntaxError: Non-UTF-8 code starting with \xc0 in file but no encoding declared; see http://p
成功解决 SyntaxError: Non-UTF-8 code starting with \xc0 in file but no encoding declared; see http://p
|
Python
SyntaxError: Non-ASCII character ‘\xe6‘ in file E:/pythondemo/example2.py on line 2, but no encoding
SyntaxError: Non-ASCII character ‘\xe6‘ in file E:/pythondemo/example2.py on line 2, but no encoding
241 0
|
XML 数据格式
因为CircleImageView导致Binary XML file line #96: Error inflating class <unknown>
因为CircleImageView导致Binary XML file line #96: Error inflating class <unknown>
160 0
SyntaxError: Non-ASCII character '\xe8' in file lane_detector.py on line 5, but no encoding declared;
在进行编译运行的时候报的错,此错是中文乱码的问题,就算是注释也不行.我们需要指定字符集