python post提交json数据(要求其中一个属性值是GBK编码)怎么做

def post_json(self):
    url = "http://www.baa.com"
    msg = '订票'.encode("gbk").decode("gbk")
    data = {
        'id': 1000,
        'msg': msg,
        'sender': 201
    }
    params = json.dumps(data)
    res = requests.post(url, json=params)

尝试过上面的代码。服务器收不到gbk编码的msg.该如何做?困扰好久

直接发送gbk编码的数据试试?题主那样编码有解码回去还是订票这个2个字没意义。

def post_json(self):
    url = "http://www.baa.com"
    msg = '订票'#.encode("gbk").decode("gbk")
    data = {
        'id': 1000,
        'msg': msg,
        'sender': 201
    }
    params = json.dumps(data)
    res = requests.post(url, data=params.encode('gbk'))

img