#数据分组
data = [1,2,3,4,5,6,7,8,9,10]
#数据条数
step = 2
data_list = [data[i:i + step] for i in range(0, len(data), step)]
print(data_list)
输出结果:
[[1, 2], [3, 4], [5, 6], [7, 8], [9, 10]]
#数据分组
data = [1,2,3,4,5,6,7,8,9,10]
#数据条数
step = 2
data_list = [data[i:i + step] for i in range(0, len(data), step)]
print(data_list)
输出结果:
[[1, 2], [3, 4], [5, 6], [7, 8], [9, 10]]