Home > Article > Backend Development > Detailed introduction to python3 Queue (one-way queue)
Create queue
import queue q = queue.Queue()
empty (if the queue is empty, return True)
##
import queue q = queue.Queue()print(q.empty())#输出:Truefull (if If the queue is full, return True)
import queue q = queue.Queue(1) #指定队列大小q.put('a')print(q.full())#输出:Trueput (put an element into the queue) get (remove an element from the queue) first-in-first-out principle
import queue q = queue.Queue() q.put('a') q.put('b')print(q.get())#输出:aget_nowait (remove an element immediately, without waiting)
#占位put_nowait (put an element immediately, without waiting)
#占位join(block the calling thread until all tasks in the queue are processed)
#占位qsize(return to the queue Number of elements)
import queue q = queue.Queue() q.put('a') q.put('b')print(q.qsize())#输出:2task_done (After completing a task, send a signal to the queue where the task has been completed)
#占位
The above is the detailed content of Detailed introduction to python3 Queue (one-way queue). For more information, please follow other related articles on the PHP Chinese website!