python 报错‘Non-ASCII’

  • Post author:
  • Post last modified:2021-03-12
  • Post category:网络人生
  • Post comments:0评论

在Python中运行时出现 SyntaxError: Non-ASCII character ‘\xe9’ in file …

因为没有在文件第一行 申明 utf-8 编码的缘故

第一行修改为

 # -- coding: UTF-8 -- 

或者

#coding=utf-8 

发表评论