myList = [
0,
1,
2,
3,
4,
5,
6,
7,
8,
9]
segmentation = [myList[i:i+
3]
for i
in range(
0,
len(myList),
3)]
输出
[[0, 1, 2], [3, 4, 5], [6, 7, 8], [9]]
写成方法
def cut_up(myList, n):
return [myList[i:i+n]
for i
in range(
0,len(myList),n)]
转载于:https://www.cnblogs.com/HeJD/p/8702029.html
相关资源:JAVA上百实例源码以及开源项目