Python——encode()和decode()方法

字符串编码转换。

python3.x默认utf-8编码

1、encode()

方法的语法格式如下:

str.encode([encoding='utf-8'][,errors='strict'])

注意,格式中用 [] 括起来的参数为可选参数,也就是说,在使用此方法时,可以使用 [] 中的参数,也可以不使用。

2、decode()方法

bytes.decode([encoding='utf-8'],[errors='strict'])

猜你喜欢

转载自blog.csdn.net/caicai0001000/article/details/111222530