python3 中 bytes 和 string 之间的互相转换

按 utf-8 的方式编码,转成 bytes

.encode(encoding="utf-8")

按 gb2312 的方式编码,转成 bytes

.encode(encoding="gb2312")

解码成 string,默认不填

.decode()

解码成 string,使用 gb2312 的方式

.decode("gb2312")