python-上传文件的几种方式
from requests_toolbelt import MultipartEncoder import requests # from_data上传文件,注意参数名propertyMessageXml data = MultipartEncoder(fields={‘propertyMessageXml‘: (‘filename‘, open(‘D:/123.xml‘, ‘rb‘), ‘text/xml‘)}) requests.post(url=url,data=data,headers={ ‘Content-Type‘: data.content_type}) #raw上传文件 file = open(‘D:/123.xml‘,‘rb‘) requests.post(url=url,data=file.read(),headers={‘Content-Type‘:‘text/xml‘}) #binary上传文件 files={‘file‘:open(‘D:/123.xml‘,‘rb‘)} requests.post(url=url,files=files,headers={‘Content-Type‘:‘binary‘})
相关推荐
ppsurcao 2020-06-14
夜斗不是神 2020-11-17
zhjn0 2020-11-24
学习web前端 2020-11-09
waiwaiLILI 2020-11-03
raidtest 2020-10-09
myccc 2020-09-24
jzlixiao 2020-09-15
guicaizhou 2020-09-15
digwtx 2020-09-14
大秦铁骑 2020-08-19
thatway 2020-08-19
lovecodeblog 2020-08-19
codetyper 2020-08-16
comwayLi 2020-08-16
MongoDB数据库 2020-08-16
cjsyrwt 2020-08-14