python中文编码问题

来源:互联网 发布:淘宝上月销量怎样统计 编辑:程序博客网 时间:2024/05/02 04:58
#!/usr/bin/env python 
#coding=utf-8 
s="中文" 
if isinstance(s, unicode): 
#s=u"中文" 
print s.encode('gb2312') 
else: 
#s="中文" 
print s.decode('utf-8').encode('gb2312')
原创粉丝点击