python

学习过程中总结的经验

博客园 首页 新随笔 联系 订阅 管理
开发环境: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
posted on 2011-11-08 12:08  や尐莊徍左赱  阅读(222)  评论(0编辑  收藏  举报