the request was rejected because no multipart boundary was found;上传文档使用 application/octet-stream 兼容 或者直接省略content-type
import requests from http.client import HTTPConnection HTTPConnection.debuglevel=1 import requests # 请求url url = "http://ip:port/file" # 请求头 headers = { 'Authorization': '.rF7ctEMcLrNCfm65HVGnfRgNiAKyuIM...' } # 上传文件的参数 files = { "file": ("1.png", open("2.jpg", "rb"), "application/octet-stream") # "file": open("1.png", "rb") } # 发送请求 response = requests.post(url=url, headers=headers, files=files ) # 打印结果 print(response.text)
https://docs.python-requests.org/en/latest/user/quickstart/#make-a-request
https://www.w3cschool.cn/requests2/requests2-mr8f3fje.html