python Interface Automation (put request)

python Interface Automation (put request)

A, put the requested action: Update Resources

Second, the application

  1. 导包:import requests
  2. Call requests.put () method
  3. Parameters URL, data, headers, requests the same method post
  4. Response r.json () - status response json format, r.status_code response code
  5. Import Requests
     Import Requests
     # 2. The method of calling post 
    # requests the URL 
    URL = ' HTTPS: //www.*******/pc/member/sign/ ' 
    # request header 
    headers = { ' Content-type ' : ' file application / X-WWW-form-urlencoded ' }
     # request parameter 
    Data = { ' in Flag ' : ' Mobile ' ,
           ' password ' : ' e9f5c5240c0bb39488e6dbfbdb1517e0 ' ,
           ' MOBILE_PHONE ': ' ******* ' } 
    
    R & lt = requests.put (URL, Data = Data, headers = headers)
     # 3. acquisition response objects 
    Print (r.text) # text format 
    Print (r.json ()) # JSON format 
    # 4 acquires the response status code 
    Print (r.status_code)
     # 5. the request for the URL 
    Print (r.url)

     

 

 

 

 

 

 

 

 

 

 

 

 

Guess you like

Origin www.cnblogs.com/jingdenghuakai/p/11805128.html