首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往
您找到你想要的搜索结果了吗?
是的
没有找到

decode encode区别_python encode函数

encode:编码 decode:解码 python内部编码方式为unicode,decode将其他编码方式转换成unicode编码方式,encode将unicode转换成其他编码方式。...因此unicode相当于一个中转: (1)decode->unicode->encode (2)encode->unicode->decode 字符串在Python内部的表示是unicode编码,因此...encode的作用是将unicode编码转换成其他编码的字符串,如str2.encode(‘gb2312’),表示将unicode编码的字符串str2转换成gb2312编码。...这种情况下,要进行编码转换,都需要先用decode方法将其转换成unicode编码,再使用encode方法将其转换成其他编码。...因此,对于这种情况做编码转换,只需要直接使用encode方法将其转换成指定编码即可。

74610

decode encode区别_python decode和encode

,字符串在Python内部的表示是unicode编码,因此,在做编码转换时,通常需要以unicode作为中间编码, 即先将其他编码的字符串解码(decode)成unicode,再从unicode编码(encode...encode的作用是将unicode编码转换成其他编码的字符串,如str2.encode(‘gb2312’),表示将unicode编码的字符串str2转换成gb2312编码。...这种情况下,要进行编码转换,都需要先用 decode方法将其转换成unicode编码,再使用encode方法将其转换成其他编码。...如下: s.decode(‘utf-8’).encode(‘utf-8’) decode():是解码 encode()是编码 isinstance(s,unicode):判断s是否是unicode编码,...”’ ”’ s=’中文’ s=s.decode(‘utf-8’) #将utf-8编码的解码成unicode print isinstance(s,unicode) #此时输出的就是True s=s.encode

1.1K10
领券