import numpy as np a = np.zeros([5]) for i in range(20): a[:-1]=a[1:] a[-1]=i print(a) 输出为 [ 15. 16. 17. 18. 19.]