线程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())
本文来自博客园,作者:一石数字欠我15w!!!,转载请注明原文链接:https://www.cnblogs.com/52-qq/p/7453265.html