python--中文比较

时间:2014-06-18 19:26:41   收藏:0   阅读:384

比较中文是否相等:

 

if str1.decode("GB2312").encode("utf-8") == str2.decode("GB2312").encode("utf-8"):

    print "=="

 

 

注: decode中时str1 str2使用的中文编码方式, encode统一用utf-8形式比较.

python--中文比较,布布扣,bubuko.com

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!