python + requests pass two kinds of parameters by

JMeter in the request parameters, we learned that when making the interface test parameters sent the request in two formats, one is Parameters, one is JSON. See how to distinguish  https://www.cnblogs.com/testlearn/p/10959217.html

That in python, how to use these two requests pass parameters format it?

Import Requests 

# Parameters Parameter body 
data = {
     " Mobile " : " 12345678901 " ,
     " password " : " 123456 " } 
RS = requests.request ( " POST " , the URL , data = data)     # transmission request, using the data transfer Parameters parameters by 
Print (F " RS: RS {} " ) 

# the JSON parameters by 
token = rs.json () [ " Data " ] [ "ticketString" ] 
Headers = {
     " token " : token,
     " the Content-the Type " : " file application / JSON " 
} 
Data = {
     " Page " :. 1 ,
     " the pageSize " : 15 } 
RS1 = requests.request ( " POST " , the URL , headers = headers, json = Data)       # transmission request, using the parameters parameters json transfer body, using headers request header 
Print (F " RS1:{rs1}")

 

Guess you like

Origin www.cnblogs.com/testlearn/p/11077831.html