eclipse 语法错误:以“\x82”开头的非 UTF-8 代码

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/15602038/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 20:14:51  来源:igfitidea点击:

SyntaxError: Non-UTF-8 code starting with '\x82'

pythoneclipse

提问by Elmer

I get this error in Eclipse while working on "Byte of Python"

在 Eclipse 中处理“Python 字节”时出现此错误

It says the error shows up in 2 lines:

它说错误显示在 2 行中:

source = ["C:\My Documents", "C:\Code"]

and

zip_command = "zip -qr {0} {1}".format(target, ? ?.join(source))

I cant really figure out what im doing wrong here.

我真的无法弄清楚我在这里做错了什么。

Here's the full error:

这是完整的错误:

SyntaxError: Non-UTF-8 code starting with '\x82' on line x, but no encoding declared; see http://python.org/dev/peps/pep-0263/for details

语法错误:第 x 行以“\x82”开头的非 UTF-8 代码,但未声明编码;有关详细信息,请参阅http://python.org/dev/peps/pep-0263/

采纳答案by root

You are using chars (curved quotes) encoded in windows-1252that cannot be decoded because it's not valid utf-8. Replace the quotes and you are good to go.

您正在使用windows-1252无法解码的字符(弯曲引号),因为它无效utf-8。替换引号,您就可以开始了。