python 编译出现SyntaxError: Non-ASCII character ‘\xe8‘ in file in file serverinfo.py on line 4, but no

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

问题主要是编译中出现了中文或特殊字符,使用以下方式解决:
在文件头部第1行加上编码

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

posted on 2024-10-31 08:50  数据派  阅读(5)  评论(0编辑  收藏  举报