python解码和转码:byte类型

#decoding转为字符串:解码;encode转为二进制:转码
msg = "我爱北京天安门"
print(msg.encode()) #encode默认utf-8
print(msg.encode(encoding="utf-8").decode(encoding="utf-8"))

猜你喜欢

转载自www.cnblogs.com/wzsx/p/8939850.html