python 请求头字符串转字典
headers_str = '''
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9
Accept-Encoding: gzip, deflate
Accept-Language: zh-CN,zh;q=0.9
Cache-Control: no-cache
Cookie: __utma=156575163.1457595799.1602405734.1602405734.1602405734.1; user=MDptdF81NDQwNzcxNDI6Ok5vbmU6NTAwOjU1NDA3NzE0Mjo3LDExMTExMTExMTExLDQwOzQ0LDExLDQwOzYsMSw0MDs1LDEsNDA7MSwxMDEsNDA7MiwxLDQwOzMsMSw0MDs1LDEsNDA7OCwwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMSw0MDsxMDIsMSw0MDo6Ojo1NDQwNzcxNDI6MTYxODE5MzM5ODo6OjE2MDAwMDQyODA6MjY3ODQwMDowOjE3Yzg5MDYzZmMzZWI4OTYxM2FjMWYwZThjNTY1YjhjNDo6MA%3D%3D; userid=544077142; u_name=mt_544077142; escapename=mt_544077142; ticket=827fd20e43e2fea62339c2ce8af53f4d; user_status=0; Hm_lvt_78c58f01938e4d85eaf619eae71b4ed1=1618201738; Hm_lvt_f79b64788a4e377c608617fba4c736e2=1618201762; Hm_lvt_60bad21af9c824a4a0530d5dbf4357ca=1618201762; refreshStat=off; spversion=20130314; historystock=688179%7C*%7C003032; log=; Hm_lpvt_60bad21af9c824a4a0530d5dbf4357ca=1618209232; Hm_lpvt_78c58f01938e4d85eaf619eae71b4ed1=1618209232; Hm_lpvt_f79b64788a4e377c608617fba4c736e2=1618209232; v=A6MA2C_ex_mGVYvNK7wfAIgYMuxXmDfzcSx7DtUA_4J5FM2QXWjHKoH8Dbrm
Host: data.10jqka.com.cn
Pragma: no-cache
Proxy-Connection: keep-alive
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.87 Safari/537.36 SE 2.X MetaSr 1.0
'''
pattern = '^(.*?): (.*)$'
headersdic = {}
for line in headers_str.splitlines():
splitArr = line.split(":")
if len(splitArr) <= 1:
continue
headersdic[splitArr[0]] = splitArr[1].strip()