python - 模块对象没有属性 'thread'

标签 python python-2.7 python-multithreading

我使用的是基本线程。 这是我输入的代码。

#!usr/bin/python3

import threading
class Bhai_ka_messenger(threading.Thread):
    def run(self):
        for message in range(10):
            print threading.currentThread().getName()

a=Bhai_ka_messenger(name="message send")
b=Bhai_ka_messenger(name="message receive")
a.start()
b.start()

这表示模块对象没有属性线程。 当我在在线 IDE 上运行它时,该程序可以运行。 现在我无法解决这个问题,有人可以帮忙吗?

最佳答案

您已调用本地文件 threading.py,但随后将该文件导入文件本身,导致它无法工作。

希望对您有所帮助。

关于python - 模块对象没有属性 'thread',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37414442/

相关文章:

Python 使用配置文件记录到不同的目的地

python - 如何添加/替换/删除字符串中的转义字符 - Python

python - Popen subprocess.PIPE 及其用途

python - Tkinter 在框架中加载图像

python - 如何通过知道线程 ID 来获取线程的名称?

python - Python 2 和 Python 3 之间 re 模块的变化

Python 多处理 - 'Queue' 对象没有属性 'task_done'/'join'

python - 出现条件后停止 Twisted.internet 中的 react 器

python - 如何在Python中多次运行一个线程

python - 多进程程序中线程与进程的关系