转载至 https://blog.csdn.net/weixin_34049948/article/details/86002037
1
2
3
4
a = [1,2,3,4,5,6,7,8,9,10,11]
step = 5
b = [a[i:i+step] for i in range(0,len(a),step)]
print(b)
输出
1
[[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11]]
转载至 https://blog.csdn.net/weixin_34049948/article/details/86002037
1
2
3
4
a = [1,2,3,4,5,6,7,8,9,10,11]
step = 5
b = [a[i:i+step] for i in range(0,len(a),step)]
print(b)
输出
1
[[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11]]