python 将一个列表分成指定长度
如有一个列表s=[1,2,3,4,5,6,7,8,9,10],要求切分成指定长度为2,变成[1,2,3,4,5],[6,7,8,9,10]
def split_list(init_list,n):
start = 0
end = len(init_list)//n
for i in range(n):
g = init_list[start:end]
start = end
end = start + end
print(g)