>>> x = [0,1,7,3,4,5,10]
>>> n = 3
>>> zip(*(x[i:] for i in range(n)))
[(0, 1, 7), (1, 7, 3), (7, 3, 4), (3, 4, 5), (4, 5, 10)]
If you want the result to be a list of lists instead of list of tuples, use map(list, zip(...))
.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…