先入先出、先入后出;按优先级
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
#!/usr/bin/env python # Author:Zhangmingda import queue q = queue.Queue() #先入先出 q.put('A') q.put('B') q.put('C') print(q.get()) print(q.get()) print(q.get())
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
#!/usr/bin/env python # Author:Zhangmingda import queue q = queue.LifoQueue() #先入后出 q.put('A') q.put('B') q.put('C') print(q.get()) print(q.get()) print(q.get())
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
#!/usr/bin/env python # Author:Zhangmingda import queue q = queue.PriorityQueue() #优先级策略put内容为元组,第一个为优先级代码,必须全部为数字或者字母 q.put((3,'zhangsan')) q.put((5,'lisi')) q.put((1,'wangwu')) print(q.get()) print(q.get()) print(q.get())