import json

读取json文件

with open('investment.json', 'r', encoding='utf-8') as f: data = json.load(f)

统计每个轮次的投资事件次数

round_count = {} for item in data: round = item['融资轮次'] if round in round_count: round_count[round] += 1 else: round_count[round] = 1

按照投资事件次数降序排序,次数相同按照轮次升序排序

sorted_round_count = sorted(round_count.items(), key=lambda x: (-x[1], x[0]))

将结果写入result.txt文件中

with open('result.txt', 'w', encoding='utf-8') as f: f.write('投资轮次 投资事件次数\n') for round, count in sorted_round_count: f.write(f'{round} {count}\n')

Python 代码实现:统计在线教育市场投资轮次事件

原文地址: http://www.cveoy.top/t/topic/oiZw 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录