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