你好,Python

Python中有中文,报错

 

试了下

s = '你好,Python'

print s

 运行报错

  File "testChinese.py", line 1

SyntaxError: Non-ASCII character '\xc4' in file testChinese.py on line 1, but no encoding declared; see http://www.python.org/peps/pep-0263.html

for details

 

在代码前指定编码方式,

# coding=UTF-8
s = '你好,Python'
print s

 OK!!

你可能感兴趣的:(python)