python--中文比较

比较中文是否相等:

 

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

    print "=="

 

 

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

posted @ 2014-06-16 11:54  helloweworld  阅读(2049)  评论(0编辑  收藏  举报