Live2D

获取请求头

Python 字典形式展示的服务器响应头:
>>>r.headers


{
** 'content-encoding': 'gzip',**
** 'transfer-encoding': 'chunked',**
** 'connection': 'close',**
** 'server': 'nginx/1.0.4',**
** 'x-runtime': '148ms',**
** 'etag': '"e1ca502697e5c9317743dc078f67693f"',**
** 'content-type': 'application/json'**
}
***

获取请求头字段内容

    import requests
    import json
    url = 'https://api.github.com/some/endpoint'
    payload = {'some': 'data'}
    r = requests.post(url, json=payload)
    print(r.headers)#打印请求头
    print(r.headers['Content-Type'])#打印内类型
    print(r.headers.get('Content-Type'))`
posted @ 2022-05-21 23:19  soulorelax  阅读(3)  评论(0)    收藏  举报