执行python脚本报错SyntaxError: Non-ASCII character ‘\xe8‘

执行python脚本报错
SyntaxError: Non-ASCII character '\xe8' in file test .py on line 2, but no encoding declared; see http://python.org/dev/for details

因为编译中出现了中文或特殊字符,在脚本首行加上下列内容即可

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

你可能感兴趣的:(python,开发语言)