首页 > 解决方案 > 有没有办法防止 aiohttp 将帖子表单中列表内的嵌套字典转换为字符串?

问题描述

我目前正在为一个网站编写一个 API 调用,该网站具有非常奇怪的细节,需要以下类型的表单数据: {"somehting": "something else", "important argument": [{"specific data": "4242", "second data": 0}]}

但是当我制定请求aiohttp.ClientSession()并使用测试发布请求时,https://httpbin.org/我看到 aiohttp 正在向第二个字典添加一个引号,如下所示: {"somehting": "something else", "important argument": ["{"specific data": "4242", "second data": 0}"]} 因此,当我尝试使用 api 调用时,服务器拒绝它并出现错误。

有没有办法解决这个问题或者我应该使用不同的库?

标签: python-3.xhttp-postaiohttp

解决方案


推荐阅读