Using Queue in python

前端 未结 5 1687
无人及你
无人及你 2021-02-06 23:31

I\'m trying to run the following in Eclipse (using PyDev) and I keep getting error :

q = queue.Queue(maxsize=0) NameError: global name \'queue\' is not defined<

5条回答
  •  深忆病人
    2021-02-07 00:12

    That's because you're using : from queue import *

    and then you're trying to use :

    queue.Queue(maxsize=0) 
    

    remove the queue part, because from queue import * imports all the attributes to the current namespace. :

    Queue(maxsize=0) 
    

    or use import queue instead of from queue import *.

提交回复
热议问题