python中的中文处理问题

方法一:

在文件的开头加入编码声明:

#coding= gbk

s = '谷歌'

print s

输出结果:谷歌


方法二:

在输出时进行转码:

#coding= utf-8

s = '谷歌'

print unicode(s,'gbk')

输出结果:谷歌

posted on 2011-04-24 20:35  linw  阅读(364)  评论(1)    收藏  举报

导航