实现队列的代码测试
from collections import deque
deque1 = deque(['a', 'b', 'c'])
deque1.append(1)
deque1.append(2)
deque1.append(3)
for i in range(4,20):
deque1.append(i)
print(deque1)
deque1.popleft()
print(deque1)
运行结果
E:\Python\Python38\python.exe D:/pythonprojects/python-auto-test/test/duilie.py
deque(['a', 'b', 'c', 1, 2, 3, 4])
deque(['b', 'c', 1, 2, 3, 4])
deque(['b', 'c', 1, 2, 3, 4, 5])
deque(['c', 1, 2, 3, 4, 5])
deque(['c', 1, 2, 3, 4, 5, 6])
deque([1, 2, 3, 4, 5, 6])
deque([1, 2, 3, 4, 5, 6, 7])
deque([2, 3, 4, 5, 6, 7])
deque([2, 3, 4, 5, 6, 7, 8])
deque([3, 4, 5, 6, 7, 8])
deque([3, 4, 5, 6, 7, 8, 9])
deque([4, 5, 6, 7, 8, 9])
deque([4, 5, 6, 7, 8, 9, 10])
deque([5, 6, 7, 8, 9, 10])
deque([5, 6, 7, 8, 9, 10, 11])
deque([6, 7, 8, 9, 10, 11])
deque([6, 7, 8, 9, 10, 11, 12])
deque([7, 8, 9, 10, 11, 12])
deque([7, 8, 9, 10, 11, 12, 13])
deque([8, 9, 10, 11, 12, 13])
deque([8, 9, 10, 11, 12, 13, 14])
deque([9, 10, 11, 12, 13, 14])
deque([9, 10, 11, 12, 13, 14, 15])
deque([10, 11, 12, 13, 14, 15])
deque([10, 11, 12, 13, 14, 15, 16])
deque([11, 12, 13, 14, 15, 16])
deque([11, 12, 13, 14, 15, 16, 17])
deque([12, 13, 14, 15, 16, 17])
deque([12, 13, 14, 15, 16, 17, 18])
deque([13, 14, 15, 16, 17, 18])
deque([13, 14, 15, 16, 17, 18, 19])
deque([14, 15, 16, 17, 18, 19])
Process finished with exit code 0