码迷,mamicode.com
首页 > 编程语言 > 详细

python queue

时间:2020-02-28 14:00:58      阅读:55      评论:0      收藏:0      [点我收藏+]

标签:优先级   int   queue   get   span   code   hello   priority   fifo   

先进先出

import queue

q =queue.Queue()   #FIFO

q.put(12)
q.put(hello)
q.put({"name":"yuan"})
print(q.qsize())
print(q.full())
print(q.empty())

while True:
    data = q.get()
    print(data)
    print(---)

先进后出

import queue

q =queue.LifoQueue()

q.put(12)
q.put(hello)
q.put({"name":"yuan"})

while True:
    data = q.get()
    print(data)
    print(---)

优先级

import queue

q =queue.PriorityQueue()

q.put([2,12])
q.put([1,hello])
q.put([3,{"name":"yuan"}])

while True:
    data = q.get()
    print(data[1])
    print(---)

 

python queue

标签:优先级   int   queue   get   span   code   hello   priority   fifo   

原文地址:https://www.cnblogs.com/hb15988111121/p/12376668.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!