python Interface Automation (put request)
A, put the requested action: Update Resources
Second, the application
- 导包:import requests
- Call requests.put () method
- Parameters URL, data, headers, requests the same method post
- Response r.json () - status response json format, r.status_code response code
-
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)