直接来代码
from requests_toolbelt.multipart.encoder import MultipartEncoder
利用了requests_toolbelt这个库补充requests
m = MultipartEncoder(
fields={
'file': ('名称',open("路径", 'rb'), 'video/mpeg4'),
}
)
header = {
'Content-Type': m.content_type}
rsp = requests.post(url=url, data=m,headers = header)