2016-08-05 19 views

回答

0

溶液而不numpy的:

z=list(range(1,11)) 
offset=0 
r=[] 
p=[2,3] 
for i in p*(len(z)//sum(p)): 
    r.append(z[offset:offset+i]) 
    offset+=i 

print(r) 

收益率:

[[1, 2], [3, 4, 5], [6, 7], [8, 9, 10]] 
相关问题