美文网首页
解决 syntaxerror:non-utf-8 code st

解决 syntaxerror:non-utf-8 code st

作者: IBM_LELE | 来源:发表于2019-04-15 17:42 被阅读0次

首行增加,已测试可用。

coding=gbk

程序中出现中文,运行的时候出现如下错误:

SyntaxError: Non-UTF-8 code starting with 'xc1' in file C:...xxx.py on line 8, but no encoding declared; see http://python.org/dev/peps/pep-0263/ for details

导致出错的根源就是编码问题。
解决方案是:
在程序最上面加上:

coding=gbk

这样程序就可以正常运行了。

相关文章

网友评论

      本文标题:解决 syntaxerror:non-utf-8 code st

      本文链接:https://www.haomeiwen.com/subject/amrpwqtx.html