标签:pre nbsp bsp priority color zha class 先进先出 put
线程队列
import queue #普通队列函数 q = queue.Queue(2)#队列大小 q.put("a") q.put("b") #先进先出,后进后出 print(q.get()) print(q.get()) #a #b
堆栈
#堆栈 duizhan = queue.LifoQueue() duizhan.put("a") duizhan.put("b") #先进后出,后进先出 print(duizhan.get()) print(duizhan.get()) #b #a
优先级堆栈
#优先级队列 q3 = queue.PriorityQueue() q3.put((-100,"c")) q3.put((10,"a")) q3.put((1,"b")) #依照优先级取值,数值越小,优先级高 print(q3.get()) #(-100, ‘c‘)
标签:pre nbsp bsp priority color zha class 先进先出 put
原文地址:https://www.cnblogs.com/msj513/p/9952963.html