对于一列数字的操作,数组更为合适一些,array.array并且处理的速度更快。 队列 from collections import deque dq = deque(range(10),maxlen=10) print(dq) 生成的数组: deque([0, 1, 2, 3, 4, 5, 6, 7, 8, 9], maxlen=10) dq.extendleft([10,20,30]) deque([30, 20, 10, 0, 1, 2, 3, 4, 5, 6], maxlen=10) #从队列的左侧一个一个添加元素