No module named 'Queue'

前端 未结 1 1098
南方客
南方客 2020-12-19 05:11

My import of Python modules

import Queue
from threading import Thread
import time

But when I run code

File \"b1.py\", line          


        
相关标签:
1条回答
  • 2020-12-19 06:01

    On Python 2, the module is named Queue, on Python 3, it was renamed to follow PEP8 guidelines (all lowercase for module names), making it queue. The class remains Queue on all versions (following PEP8).

    Typically, the way you'd write version portable imports would be to do:

    try:
        import queue
    except ImportError:
        import Queue as queue
    
    0 讨论(0)
提交回复
热议问题