如何在python中进行表单数据请求?

How to make form data request in python?

如何通过在 Python 中上传文件来创建以下多部分表单数据请求?

------WebKitFormBoundaryKVAJlF8rFOTxL7jq
Content-Disposition: form-data; name="file"; filename="txtresume.txt"
Content-Type: text/plain
------WebKitFormBoundaryKVAJlF8rFOTxL7jq-- 

还有我如何 post 这个请求 python

您可以使用请求模块来 post 文件

import reqeusts
url = 'http://yoururl/'
files = {'file': open('xxx.xls', 'rb')} # or files = {'file': ('xxx.xls', open('xxx.xls', 'rb'), 'application/vnd.ms-excel', {'Expires': '0'})}
r = reqeusts.post(url, files=files)

有关更多资源,您可以查看此 link