似乎无法将队列导入 python

Can't seem to import queue into python

我正在学习如何在 python

中创建队列的教程

但是我过不了第一关:

当我尝试导入队列模块并尝试创建队列时

import queue

# Initializing a queue
qW = queue.Queue(maxsize=20)

# qsize() give the maxsize of the Queue
print(qW.qsize())

我收到这个错误

AttributeError: partially initialized module 'queue' has no attribute 'Queue' (most likely due to a circular import)

您可能对脚本文件夹中的文件使用了相同的名称

确保您的当前文件或当前工作目录中的任何其他文件未命名为 queue.py Python 可能正在导入它而不是标准库。