【发布时间】:2021-12-27 06:42:37
【问题描述】:
我正在尝试将以下 curl 转换为 python 请求。此请求会上传一个 zip 文件。
curl -k -i -X POST --form 'session.id=e7a29776-5783-49d7-afa0-b0e688096b5e' --form 'ajax=upload' --form 'file=@myproject.zip;type=application/zip' --form 'project=MyProject' https://localhost:8443/manager
使用 curl 到 python 转换工具 - 我明白了
import requests
files = {
'session.id': (None, 'e7a29776-5783-49d7-afa0-b0e688096b5e'),
'ajax': (None, 'upload'),
'file': ('myproject.zip;type', open('myproject.zip;type', 'rb')),
'project': (None, 'MyProject'),
}
response = requests.post('https://localhost:8443/manager', files=files, verify=False)
但这不起作用
【问题讨论】:
标签: python python-3.x linux curl