当前位置: 代码迷 >> 综合 >> [python] SyntaxError: Non-ASCII character ‘\xe6‘ in file xxx.py on line 4, but no encoding declared;
  详细解决方案

[python] SyntaxError: Non-ASCII character ‘\xe6‘ in file xxx.py on line 4, but no encoding declared;

热度:97   发布时间:2023-12-12 01:17:12.0

error

执行python报错

SyntaxError: Non-ASCII character ‘\xe6’ in file xxx.py on line 4, but no encoding declared; see http://python.org/dev/peps/pep-0263/ for details

reason

代码中存在中文注释

resolution

在文件第一行添加

# encoding=utf-8

  相关解决方案