我正在将用 Python 2 编写的源代码转换为 Python 3,我偶然发现了这一点:
from Queue import Queue, Empty
我把它改为:
from multiprocessing import Queue, Empty
但这给了我一个例外:
ImportError: cannot import name 'Empty'
我该如何解决?
multiprocessing.Queue https://docs.python.org/3/library/multiprocessing.html#exchanging-objects-between-processes用于流程,不要让大小写混淆。Queue https://docs.python.org/2.7/library/queue.html,已更名为queue https://docs.python.org/3.6/library/queue.html在Python 3中,用于线程。
Both Empty https://docs.python.org/3.6/library/queue.html#queue.Empty and Queue https://docs.python.org/3.6/library/queue.html#queue.Queue位于queue
模块,因此从那里获取它们。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)