今天eclipse中写了一小段程序,其中包含中文的输出和注释,运行的时候报错如下:SyntaxError: Non-ASCII character "/xe4" in file G:/eclipse-work/XMLRPC/src/rpcserver.py on line 19, but no encoding declared; see http://www.python.org/peps/pep-0263.html for details 于是顺着错误消息给出的URL看看到底是为啥。打开后发现原来是《 PEP 0263 -- Defining Python Source Code Encodings <!--This HTML is auto-generated.DO NOT EDIT THIS FILE!If you are writing a newPEP, see http://www.python.org/dev/peps/pep-0001 for instructions and linksto templates.DO NOT USE THIS HTML FILE AS YOUR TEMPLATE!-->》,文章的大概意思如下:1.Python will default to ASCII as standard encoding if no other encoding hints are given.To define a source code encoding, a magic comment mustbe placed into the source files either as first or second line in the file, such as: # coding=<encoding name>