首页 > 解决方案 > 如何在没有文件的情况下在 Python 正文中发送 multipart/form-data 请求

问题描述

它与其他问题不重复我想知道谁可以将身体数据作为多表单数据发送。在其他问题中,它提到了如何上传文件。我真的没有要上传的文件,或者我可能不知道该怎么做。请帮忙

我必须发送一个 Post 请求,其中正文是 multipart/form-data

import requests    
url = 'https://myapp-local/api/address'
    headers = {'Accept':'application/json','Content-Type':'multipart/form-data','token': token, 'referer':'https://myapp-local/api/address'}

现在在正文中,我需要发送一些值,例如

address_name=Ram, current_time=1557249595, house_no=303, district=theni, address_type=permemnant 

我需要将这些值作为表单数据发送。我怎样才能做到这一点?请帮忙

标签: pythonrestapi

解决方案


推荐阅读