线程queue

1 import queue
2 q = queue.Queue()      #模拟队列,先进先出
3 q.put('first')
4 q.put('second')
5 q.put('third')
6 
7 print(q.get())
8 print(q.get())
9 print(q.get())
模拟队列
1 import queue
2 q = queue.LifoQueue()      #模拟堆栈,先进后出
3 q.put('first')
4 q.put('second')
5 q.put('third')
6 
7 print(q.get())
8 print(q.get())
9 print(q.get())
模拟堆栈
1 import queue
2 q = queue.PriorityQueue()      #put进去一个元组,第一个元素设置优先级,越小越高
3 q.put((10,'first'))
4 q.put((30,'second'))
5 q.put((20,'third'))
6 
7 print(q.get())
8 print(q.get())
9 print(q.get())
设置优先级

 

posted @ 2017-08-30 15:15  一石数字欠我15w!!!  阅读(306)  评论(0编辑  收藏  举报