{ "data": [('a', 'b', 'c', 'd', 'e'), (1, 2, 3, 4, 5), (5, 6, 7, 8, 5), (11, 22, 33, 44, 88), (33, 55, 66, 77, 87), (12, 34, 43, 44, 22), (12, 65, 87, 14, 11), (12, 33, 56, 12, 32), (44, 54, 22, 15, 43), (87, 76, 98, 53, 44), (27, 92, 14, 65, 53)], "result": [] } for item in data: first = item[0] rest = item[1:] partitions = [rest[i:i+3] for i in range(0, len(rest), 3)] result.append([(first,) + partition for partition in partitions]) print(result)

将数据按照第一个数据永远在第一,后续数据以第一个+后续三个三个划分

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

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