参考链接:https://www.cnblogs.com/yoyoketang/p/6828424.html
1.payload参数是字典类型,传到如下图的form里
参考代码:
import requests import warnings warnings.filterwarnings('ignore') help(requests) payload = dict(username="***", password="***") r = requests.post("https://***.***.com/v1/login", data=payload, verify=False) print(r.status_code)
2.json:
1)post的body是json类型,也可以用json参数传入。
2)先导入json模块,用dumps方法转化成json格式。
3)返回结果,传到data里
参考代码:
import requests import warnings warnings.filterwarnings('ignore') header = {"Content-Type": "application/json"} payload = {"username": "13799438434", 'password':"123456"} r = requests.post("https://**.***.com/v1/login", data=payload, verify=False) print(r.status_code) print(r.json())