我有一个类似于下面的列表
['a','b','c','d','e','f','g','h','i','j']
我想用索引列表分隔
[1,4]
在这种情况下,它将是
[['a'],['b','c'],['d','e','f','g','h','i','j']]
As
[:1] =['a']
[1:4] = ['b','c']
[4:] = ['d','e','f','g','h','i','j']
情况2:如果索引列表是
[0,6]
这将是
[[],['a','b','c','d','e'],['f','g','h','i','j']]
As
[:0] = []
[0:6] = ['a','b','c','d','e']
[6:] = ['f','g','h','i','j']
情况 3 如果索引是
[2,5,7]
这将是
[['a','b'],['c','d','e'],['h','i','j']]
作为
[:2] =['a','b']
[2:5] = ['c','d','e']
[5:7] = ['f','g']
[7:] = ['h','i','j']