当前位置:网站首页 > 更多 > 编程开发 > 正文

[Python] request请求头快速加引号

作者:CC下载站 日期:2020-03-01 00:00:00 浏览:60 分类:编程开发

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, ''': '',', line))

您需要 登录账户 后才能发表评论

取消回复欢迎 发表评论:

关灯