关于python2中的unicode和str互相转化
python 牛啊,自转码
is 是强格式对齐的,推荐使用is 和is not 代替== !=
>>> x1 = 'x'.decode('utf-8') >>> x1 u'x' >>> x2 = u'x'.encode('utf-8') >>> x2 'x' >>> type(x1) <type 'unicode'> >>> type(x2) <type 'str'> >>> x1 is x2 False >>> x1 == x2 True >>> x1 != x2 False