电脑上按Ctrl + D,下次访问更方便
服务分类

Python报错 Non-UTF-8 code starting with ‘\xef’ in file xxx

Python报错如下:

SyntaxError: Non-UTF-8 code starting with '\xef' in file C:/Users/yourname/Documents/python/python_test.py on line 10, but no encoding declared; see http://python.org/dev/peps/pep-0263/ for details

解决办法:

在py文件的最上面加上:

# -*- coding:utf-8 -*-

作为py文件的第一行。

这样就没问题了!

发表回复

登录后才能评论
联系我们

联系我们

微信客服:

fuwu360微信客服

工作时间:周一至周五,9:30-18:30,节假日休息

返回顶部