python之requests模塊中的params和data的區別


params的時候之間接把參數加到url后面,只在get請求時使用:

 1 import requests
 2 url='https://api.ireaderm.net/account/charge/info/android'
 3 data={'recharge':36,'fee_id':'ireader_nonrenew_vip'}
 4 header={
 5     'X-ZY-Timestamp':'1502097587609',
 6     'X-ZY-Sign':'xxxxxxxxxxxxxxxxxxxxxxxxxxx',
 7     'X-ZY-Client':'xxxxxxxxxxxxxxxxxxxxxx'    
 8     }
 9 res=requests.get(url,params=data,headers=header)
10 print(res.text)
 1 import requests
 2 url='https://api.ireaderm.net/account/charge/info/android?recharge=36&fee_id=ireader_nonrenew_vip_1_fee_usd_1m3d99'
 3 header={
 4     'X-ZY-Timestamp':'1502097587609',
 5     'X-ZY-Sign':'xxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
 6     'X-ZY-Client':'xxxxxxxxxxxxxxxxxxxxxxxxxxxx'
 7     
 8     }
 9 res=requests.get(url,headers=header)
10 print(res.text)

data用於post請求時:

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM