python(queue.PriorityQueue 存储数据时可设置优先级的队列)

import queue

q = queue.PriorityQueue()
q.put((18,"Sooele"))
q.put((28,"Sooele1"))
q.put((5,"Sooele2"))
q.put((8,"Sooele3"))

print(q.get())
print(q.get())
print(q.get())
print(q.get())
class  queue.Queuemaxsize = 0 )#先入先出
class  queue.LifoQueuemaxsize = 0 )#last in fisrt out 
class  queue.PriorityQueuemaxsize = 0 )#存储数据时可设置优先级的队列

发表评论