Python3 Queue (one-way Queue), python3queue Queue
Create a queue
Import queueq = queue. Queue ()
Empty (True if the queue is empty)
Import queueq = queue. Queue () print (q. empty () # output: True
Full (True if the queue is full)
Import queueq = queue. Queue (1) # specify the queue size q. put ('A') print (q. full () # output: True
Put (put an element into the queue) get (retrieve an element from the queue) first-in-first-out principle
Import queueq = queue. Queue () q. put ('A') q. put ('B') print (q. get () # output:
Get_nowait (retrieve an element immediately without waiting)
# Placeholder
Put_nowait (put an element immediately without waiting)
# Placeholder
Join (blocking call threads until all tasks in the queue are processed)
# Placeholder
Qsize (return the number of elements in the queue)
Import queueq = queue. Queue () q. put ('A') q. put ('B') print (q. qsize () # output: 2
Task_done (send a signal to the completed queue after a task is completed)
# Placeholder