python怎么把字符转换为unicode编码?
实现代码如下:a = 'abce'# print type(a)b = a.decode("ascii"
)# print type(b)c = a.decode("ascii").encode("utf-8"
)# print type(c)在python中进行编码转换都是通过unicode作为中间值实现的。所以要先decode成unicode字符,然后再使用encode转换成utf-8编码的str。可以把注释取消了,看下转换过程中的类型。
Copyright © 广州京杭网络科技有限公司 2005-2025 版权所有 粤ICP备16019765号
广州京杭网络科技有限公司 版权所有