python基础知识笔记

1.python中decode解码和encode编码

unicode:4byte表示的unicode编码,也是python内部使用的字符串编码方式。
utf-8:最少1byte表示的unicode编码方式。

python默认编码:unicode

decode:从指定编码方式解码为unicode方式。

encode: 从unicode编码为指定编码方式。

在python中,所有格式的中间编码方式就是unicode,需要从编码A转换为编码B,只需要

string.decode("A").encode("B")

就可以了。

猜你喜欢

转载自www.cnblogs.com/xfvipp/p/9077080.html