msg = "我爱你"
print(msg.encode(encoding='utf-8')) #转成bytes类型文件 编码
print(msg.encode(encoding="utf-8").decode(encoding="utf-8")) #转回str字符串类型 先编码-->解码
string --> bytes encode编码
bytes --> string decode解码
转载于:https://blog.51cto.com/13707996/2301454
msg = "我爱你"
print(msg.encode(encoding='utf-8')) #转成bytes类型文件 编码
print(msg.encode(encoding="utf-8").decode(encoding="utf-8")) #转回str字符串类型 先编码-->解码
转载于:https://blog.51cto.com/13707996/2301454