队列

from queue import Queue

# 队列 --- 先进先出
q = Queue()
for i in range(5):
    q.put(i)
while not q.empty():
    print(q.get())
0
1
2
3
4
from queue import LifoQueue
# 队列 --- 先进后出   类似于栈
q = LifoQueue()
for i in range(10, 15):
    q.put(i)
while not q.empty():
    print(q.get())
14
13
12
11
10
posted @ 2020-11-04 13:06  疯狂列表推导式  阅读(71)  评论(0编辑  收藏  举报