This should do the trickY = 961X = 832all_ = np.random.rand(832*961)# Iterating over the values of yfor i in range(1,Y): # getting the indicies from the array we need # i - 1 = Start # X*i = END # 2 is the step indicies = list(range(i-1,X*i,2)) # np.take slice values from the array or get values corresponding to the list of indicies we prepared above required_array = np.take(indices=indices)
对于对此解决方案感兴趣的任何人(每次迭代,而不是每次迭代增加移位):for i in range(Y): shift = X * (i // 2) begin = (i % 2) + shift end = X + shift print(f'{begin}:{end}:2')