本文转载自:http://blog.csdn.net/wyb_hardworking/article/details/19562971

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

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

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

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-12-23
  • 2021-10-04
  • 2021-09-11
  • 2021-08-05
  • 2022-12-23
猜你喜欢
  • 2022-02-20
  • 2022-12-23
  • 2022-01-28
  • 2021-10-14
  • 2022-01-28
  • 2021-09-18
  • 2022-01-01
相关资源
相似解决方案