request请求头快速加引号

Lan
Lan
2020-03-01 / 0 评论 / 604 阅读 / 正在检测是否收录...
温馨提示:
本文最后更新于2022年03月01日,已超过788天没有更新,若内容或图片失效,请留言反馈。
import re

headers_str = '''
origin: https://sou.zhaopin.com
referer: https://sou.zhaopin.com/?p=3&jl=765&kw=python&kt=3
sec-fetch-dest: empty
sec-fetch-mode: cors
sec-fetch-site: same-site
user-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.122 Safari/537.36
'''
pattern = '^(.*?): (.*)$'

for line in headers_str.splitlines():
    print(re.sub(pattern, ''\1': '\2',', line))
0

评论 (0)

取消