Python小练习
2022/4/21 20:42:52
本文主要是介绍Python小练习,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
import requests def getDotData(): url = "http://xxxx/xxx/xxx" headers = { "accept": "application/json", "Accept-Encoding": "gzip,deflate", "Accept-Language": "zh-CN,zh;q=0.9", "access-control-allow-origin": "*", "Connection": "keep-alive", "Content-Length": "92", "content-type": "application/json;charset=utf-8;text/plain", "graytoken": "1", "Host": "xxx", "Origin": "http://xxxx.com", "Referer": "http://xxx.com/", "User-Agent": "Mozilla/5.0(WindowsNT10.0;WOW64)AppleWebKit/537.36(KHTML,likeGecko)Chrome/96.0.4664.45Safari/537.36" } data = { "nodeId":"364ed45f", "pageNum":1, "pageSize":3000, "xxxx":"xxx", "name":"", "tcId":"" } req = requests.post(url=url, headers=headers, json=data).json() # 要用json传参 return req def resAllTestCase(): myReq = getDotData() if 'E0000' == myReq['code']: data = myReq['data'] if 'testCaseList' in data: testCaseList = data.get('testCaseList') myList = [] myDict = {} for case in testCaseList: creatorName = case.get('creatorName') myList.append(creatorName) for i in myList: myDict[i] = myList.count(i) # 统计列表中的人员出现次数,并添加在字典中 myDictSorted = sorted(myDict.items(), reverse=True, key=lambda item: item[1]) # 按照字典的value进行降序排列 return myDictSorted if __name__ == '__main__': print(resAllTestCase())
这篇关于Python小练习的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-12-20Python编程入门指南
- 2024-12-20Python编程基础与进阶
- 2024-12-19Python基础编程教程
- 2024-12-19python 文件的后缀名是什么 怎么运行一个python文件?-icode9专业技术文章分享
- 2024-12-19使用python 把docx转为pdf文件有哪些方法?-icode9专业技术文章分享
- 2024-12-19python怎么更换换pip的源镜像?-icode9专业技术文章分享
- 2024-12-19Python资料:新手入门的全面指南
- 2024-12-19Python股票自动化交易实战入门教程
- 2024-12-19Python股票自动化交易入门教程
- 2024-12-18Python量化入门教程:轻松掌握量化交易基础知识