用python实现提取HTTP响应里对应参数的值

import re
import xlwt

f=open("info.txt","r",encoding="utf-8")
file=f.read()
f.close()

# 把要提取的多个参数名写在列表内
fields=["deliveryRowId","materialNo"]

workbook = xlwt.Workbook(encoding = 'utf-8')
worksheet = workbook.add_sheet('Worksheet_yyn')

for field in fields:
    # 查找数据的正则表达式
    search_key='"'+field+'":"(.*?)"'
    result_data=re.findall(search_key,file)


    i=1
    j=fields.index(field)
    worksheet.write(0,j, label=field)
    for data_id in result_data:
        worksheet.write(i,j, label=data_id)
        i=i+1
workbook.save('test_info.xls')

上一篇:java web实现excel模版下载功能(1)


下一篇:vue项目接收二进制流展示表格