python中requests.request()用法

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"
        }

更多资料:

requests.request()方法解析_在路上很酷的博客-CSDN博客

猜你喜欢

转载自blog.csdn.net/qq_39208536/article/details/130369249