python3请求发布表单数据

时间:2021-02-10 13:15:00

标签: python python-3.x python-requests postman

如何在 python 请求库中发布以下请求? enter image description here

它适用于邮递员,但是当我尝试在 python 请求中运行它时,它显示了错误的结果。 这是我的代码:

data ={'state': {'no': state_number}}
        input= {'input':data}
        headers = {'Content-type': 'multipart/form-data'}
        state_list = requests.post(url="http://myurl.com",data=input,headers=headers).json()

1 个答案:

答案 0 :(得分:2)

在邮递员中你可以生成python代码:

enter image description here

enter image description here