开发环境:eclipse3.2.1+PyDev 代码: def buildConnectionString(params): """this is the second example for python是很出色的开源编程语言. Returns string.""" return ";".join(["%s=%s" % (k, v) for k, v in params.items()]) if __name__ == "__main__": myParams = {"server":"192.168.1.16", \ "database":"KYES1", \ "uid":"sa", \ "pwd":"xian" \ } print buildConnectionString(myParams) 运行结果: SyntaxError: Non-ASCII character '\xe6' in file D:\work\aa\src\d\two.py on line 3, but no encoding declared; see http://www.python.org/peps/pep-0263.html for details 原因: doc string有中文 解决: #coding=GB2312 再次运行结果: pwd=xian;database=KYES1;uid=sa;server=192.168.1.16