【问题标题】:ModuleNotFoundError: No module named 'Queue'ModuleNotFoundError:没有名为“队列”的模块
【发布时间】:2019-06-09 04:58:23
【问题描述】:

我正在用 Python 编写 A* 搜索算法,为此我需要 PriorityQueue 库来存储节点的子节点。我尝试了不同的方法,但错误仍然存​​在。

我尝试了import PriorityQueue, Queue 以及我在网上找到的其他一些东西。

from Queue import PriorityQueue

此导入不适用于我。

【问题讨论】:

    标签: python-3.7


    【解决方案1】:

    如果您使用的是 python 3,则需要

    import queue as Q 
    

    对于python

    import Queue as Q
    

    然后实例化一个 PQ 只需使用

    q = Q.PriorityQueue()
    

    【讨论】:

      猜你喜欢
      • 2019-03-28
      • 2022-01-07
      • 1970-01-01
      • 2017-12-14
      • 2020-12-10
      • 2021-09-02
      • 2020-10-10
      • 2022-01-06
      相关资源
      最近更新 更多