跳到内容
Lan小站-嗯,不错!
首页 / Python / python爬虫头部文件自动加引号脚本
python爬虫头部文件自动加引号脚本

Python

python爬虫头部文件自动加引号脚本

年份
2020
分类
Python

image.png

import re

headers_str = '''
formhash: f0f241b5
qdxq: nu
qdmode: 2
todaysay: 
fastreply: 0
'''
pattern = '^(.*?): (.*)$'

for line in headers_str.splitlines():
    print(re.sub(pattern, '\'\\1\': \'\\2\',', line))
上一篇
试题 算法训练 求平方和
下一篇
pycharm连接GitHub出现Connection reset
← 全部作品

Lan小站-嗯,不错!

© 2026

回到首页 →