requests.request() 用法:
res = requests.request(method="post", url=url, data=datas, headers=headers)
1、method:
method: 支持 GET, OPTIONS, HEAD, POST, PUT, PATCH, or DELETE.
method="get"
method="post"
2、url:
url 为字符串
3、data
data 为 json 。
新建datas为字典,然后将字典转换为json。 datas = json.dump(datas)
datas["username"] = username
datas["password"] = password
headers = {
"Content-Type":"application/json",
}
datas = json.dumps(datas)
4、headers 为字典
headers = {
"Content-Type":"application/json",
"Accept-Encoding":"gzip, deflate, br"
}
更多资料: