# 1、安装
pip install copyheaders
2、使用方式
直接看代码:
from copyheaders import headers_raw_to_dict
str = b'''
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3
Accept-Encoding: gzip, deflate
Accept-Language: zh-CN,zh;q=0.9
Connection: keep-alive
Cookie: UM_distinctid=168f06fbeb246b-04277d3e392091-1333063-140000-168f06fbeb3a1b; CNZZDATA3302454=cnzz_eid%3D1674373702-1550220021-https%253A%252F%252Fwww.baidu.com%252F%26ntime%3D1552444290
Host: www.bejson.com
If-Modified-Since: Wed, 13 Mar 2019 02:58:11 GMT
If-None-Match: W/"5c8871c3-a7fd"
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.75 Safari/537.36
'''
headers = headers_raw_to_dict(str)
print(headers)
print(type(headers))