python怎么把字符转换为unicode编码

来源:魅力女性吧 1.35W
python怎么把字符转换为unicode编码

实现代码如下:a = 'abce'# print type(a)b = de("ascii"

)# print type(b)c = de("ascii")de("utf-8"

)# print type(c)在python中进行编码转换都是通过unicode作为中间值实现的。所以要先decode成unicode字符,然后再使用encode转换成utf-8编码的str。可以把注释取消了,看下转换过程中的类型。

热门标签