requests 上傳圖片

指定圖片大小  調用接口上傳文件html

url = '/root/img/'python

out_url = '/root/img/remote/'api

from PIL import Imageapp

im = Image.open(url+'123.jpg')ide

out_img = im.resize(('wide','height'),Image.ANTIALIAS)post

out_img.save(out_url+'123,jpg')url

data = {'cloumn':sys}xml

files = {'cloumn':('123.jpg',open(out_url+'123.jpg','rb'),'image/jpg')}htm

res = requests.post(request_url,data=data,files=files)blog

res.content

requestss帶證書上傳訪問https

xmm='<xml><openid>o3V8St1ujI6w7dJfZkvs</openid><check_name>NO_CHECK</check_name><nonce_str>mtna85R5E</nonce_str><mchid>1229457202</mchid><sign>45454802</sign><mch_appid></mch_appid><spbill_create_ip>114.215.148.27</spbill_create_ip><partner_trade_no>6ebe6588d93711e6adbf00163e04390d</partner_trade_no><re_user_name>Tcoll</re_user_name><amount>100</amount><desc>aaa</desc></xml>'

url = 'https://api.mch.weixin.qq.com/mmpaymkttransfers/promotion/transfers'

res = requests.post(url,data=xml,cert=('/home/123.pem','/home/456.pem'),verify=false)

參考:http://docs.python-requests.org/en/latest/user/advanced/#ssl-cert-verification

            http://www.cnblogs.com/tk091/p/3671160.html

相關文章
相關標籤/搜索