过程:
将其他编码的字符解码(decode)为unicode;
将unicode编码的字符编码(encode)为另一种编码。
eg:
str.decode('gb2312') -----将gb2312编码的字符串str转换为unicode编码
str.encode('GBK') -----将unicode编码的字符串str转换为GBK编码

本文阐述了字符编码转换的核心过程:先将源编码如gb2312解码为unicode,再将unicode编码为目标编码如GBK。通过实例解析,帮助读者理解编码转换的基本原理。
过程:
将其他编码的字符解码(decode)为unicode;
将unicode编码的字符编码(encode)为另一种编码。
eg:
str.decode('gb2312') -----将gb2312编码的字符串str转换为unicode编码
str.encode('GBK') -----将unicode编码的字符串str转换为GBK编码

转载于:https://www.cnblogs.com/haocao-niu/p/11443564.html

被折叠的 条评论
为什么被折叠?