参考Python字符串的编码与解码(encode与decode)
字符串在Python内部的表示是unicode编码
- decode解码实际上是把其他编码转成unicode
str1.decode(‘gb2312’),表示将gb2312编码的字符串转换成unicode编码
- encode编码实际上是吧unicode转成其他编码
如str2.encode(‘gb2312’),表示将unicode编码的字符串转换成gb2312编码。
参考Python字符串的编码与解码(encode与decode)
字符串在Python内部的表示是unicode编码
str1.decode(‘gb2312’),表示将gb2312编码的字符串转换成unicode编码
如str2.encode(‘gb2312’),表示将unicode编码的字符串转换成gb2312编码。