The queue process thread _

(1) First In First Out

import queue
q=queue.Queue()
q.put('first')
q.put('second')
q.put('third')

print(q.get())
print(q.get())
print(q.get())
'''
first
second
third
'''

 

(2) LIFO

import queue
q=queue.LifoQueue()
q.put('first')
q.put('second')
q.put('third')

print(q.get())
print(q.get())
print(q.get())
'''
third
second
first
'''


 

(3) Priority: The smaller the number, the higher priority

import queue
q=queue.PriorityQueue() q.put((20,"first")) q.put((10,"second")) q.put((30,"third")) print(q.get()) print(q.get()) print(q.get()) ''' (10, 'second') (20, 'first') (30, 'third')

 

Guess you like

Origin www.cnblogs.com/hapyygril/p/12590873.html