decode、encode中文编码问题 (python 2)

xiaoxiao2021-02-28  42

s=”中文abc” //utf8编码 su=u”中文abc” //unicode 编码 若要想将s编码成utf8,必须要求s是Unicode编码。 s.encode(“utf8”)错误 s.decode(“gb2312”).encode(“utf8”); //先将s解码,(gb2312是s的系统编码方式)python会解码成unicode码,然后编码成utf8.

转载请注明原文地址: https://www.6miu.com/read-2629834.html

最新回复(0)