pyhon 字典表达式处理cookies headers

###

# headers处理
headers = """Host:match.yuanrenxue.com
content-length: 0
pragma: no-cache
cache-control: no-cache
sec-ch-ua: "Chromium";v="94", "Google Chrome";v="94", ";Not A Brand";v="99"
sec-ch-ua-mobile: ?0
user-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/94.0.4606.71 Safari/537.36
sec-ch-ua-platform: "macOS"
accept: */*
origin: https://match.yuanrenxue.com
sec-fetch-site: same-origin
sec-fetch-mode: cors
sec-fetch-dest: empty
referer: https://match.yuanrenxue.com/match/3
accept-encoding: gzip, deflate, br
accept-language: zh-CN,zh;q=0.9
cookie: sessionid=2mzsjq18db00jmf6lau5xj03xqqg2crs"""

print({i.split(":")[0]:i.split(":")[1] for i in headers.split("\n")})

 

###

# cookie处理cookies = "m_lvt_0362c7a08a9a04ccf3a8463c590e1e2f=1633781879,1633781893; Hm_lpvt_0362c7a08a9a04ccf3a8463c590e1e2f=1633781911; Hm_lvt_c99546cf032aaa5a679230de9a95c7db=1634005743; Hm_lvt_9bcbda9cbf86757998a2339a0437208e=1634005743; no-alert3=true; tk=5367912763121426793; sessionid=azgdtwa3crbnouovyr5nk1uro4l3ng6i; Hm_lpvt_9bcbda9cbf86757998a2339a0437208e=1634086125; Hm_lpvt_c99546cf032aaa5a679230de9a95c7db=1634086126"print({i.split("=")[0]:i.split("=")[1] for i in cookies.split("; ")})

 

 

 

####

 

 

 

 

###

上一篇:为什么在重写了equals()方法之后也必须重写hashCode()方法


下一篇:两数之和