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 -*-

# coding:utf-8 

你可能感兴趣的:(Linux,Windows,python)