Chinaunix

标题: python中的unicode [打印本页]

作者: pipehappy    时间: 2007-02-11 09:36
标题: python中的unicode
str = u'\u201c'
print str.encode('gb2312')

print repr(str.encode('gb2312'))
'\xa1\xb0'
print repr(str.encode('gb2312').decode('gb2312'))
u'\u201c'
print repr(unicode(ab.encode('gb2312'),'gb2312'))
u'\u201c'
从我的心里上来讲,喜欢将输入都变成unicode进行处理,然后经过合适的过程输出。但是这样做不一定效率是高的。因而需要能够在具体的地方找到合适的处理方法。
               
               
               

本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u/14802/showart_245968.html




欢迎光临 Chinaunix (http://bbs.chinaunix.net/) Powered by Discuz! X3.2