【python】练习0608
2022/6/9 1:22:55
本文主要是介绍【python】练习0608,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
#!/usr/bin/env python # -*- coding: utf-8 -*- import requests import csv import json def test(): f = open("D:/YMM/pythonscript/hyr/file/dmpt个人任务.csv", mode="w", encoding="gbk", newline="") # newline="" 去除换行 csvwriter = csv.writer(f) head_name = ["需求ID", "需求名称", "状态"] # xls表头 csvwriter.writerow(head_name) userid = {100,200.300,400} for ids in userid: url = "https://xxxxx.com/resUser/getScheduleDataByUserId?userId=" + str( ids) + "&isDevChecked=true&isTestChecked=true" \ "&isTempChecked=true " headers = { "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) " "Chrome/97.0.4692.99 Safari/537.36", "Cookie":"ajkadaiodiaodoiaods", "Content-Type": "application/json;charset=UTF-8"} resp = requests.get(url, headers=headers, verify=False) content = resp.text data = json.loads(content) child_data_list = data["data"]["trs"] for i in range(len(child_data_list)): task = child_data_list[i] reqId = task['reqId'] reqName = task['reqName'] reqStatusName = task['reqStatusName'] csvwriter.writerows([(reqId, reqName, reqStatusName)]) # 写入多行writerows f.close() if __name__ == '__main__': test()
这篇关于【python】练习0608的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-11-26Python基础编程
- 2024-11-25Python编程基础:变量与类型
- 2024-11-25Python编程基础与实践
- 2024-11-24Python编程基础详解
- 2024-11-21Python编程基础教程
- 2024-11-20Python编程基础与实践
- 2024-11-20Python编程基础与高级应用
- 2024-11-19Python 基础编程教程
- 2024-11-19Python基础入门教程
- 2024-11-17在FastAPI项目中添加一个生产级别的数据库——本地环境搭建指南