小编Yas*_*rsy的帖子

Python请求,如何向multipart/form-data请求添加内容类型

我使用 python 请求通过 PUT 方法上传文件。

仅当正文包含属性 Content-Type:i mage/png not as Request Header 时,远程 API 才接受任何请求

当我使用 python 请求时,请求被拒绝,因为缺少属性

此图片上的此请求被拒绝

我尝试使用代理,在添加了缺少的属性后,它被接受了

查看突出显示的文本

有效请求

但我不能以编程方式添加它,我该怎么做?

这是我的代码:

files = {'location[logo]': open(fileinput,'rb')} 

ses = requests.session()
res = ses.put(url=u,files=files,headers=myheaders,proxies=proxdic)
Run Code Online (Sandbox Code Playgroud)

python upload http file python-requests

4
推荐指数
1
解决办法
4234
查看次数

标签 统计

file ×1

http ×1

python ×1

python-requests ×1

upload ×1