gpt4 book ai didi

python - 在Python中的请求帖子中传递数组的数组

转载 作者:太空宇宙 更新时间:2023-11-03 16:54:19 25 4
gpt4 key购买 nike

我在python中使用了请求。我尝试发送一个帖子请求,需要发送数组的数组。这是我的代码:

import requests

def connecttomlapipost(url, vector):
headers = {'content-type': 'application/json'}
r= requests.post(url, verify=False, auth=('admin', 'admin'), data = vector, headers=headers)
return r

print connecttomlapipost('https://......', [[2,3],[1,5]])

服务器返回:错误500。我使用POSTMAN进行测试,服务器返回正确的结果

最佳答案

您正在使用 post,并且很可能有兴趣使用 dataparams。它应该是一个字典结构而不是一个列表。 See the docs.

关于python - 在Python中的请求帖子中传递数组的数组,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35564025/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com