如何在Python 3中导入线程包?

6l7fqoea  于 2023-05-23  发布在  Python
关注(0)|答案(2)|浏览(120)

我想在Python 3.6中导入线程包。但是出现了这个错误:

import thread
ModuleNotFoundError: No module named 'thread'
46qrfjad

46qrfjad1#

将其更改为import threading

ktecyv1j

ktecyv1j2#

import threading 

def main():
...

if __name__ =="__main__":

    t1 = threading.Thread(target=main, args=())
    t2 = threading.Thread(target=main, args=())
 
    t1.start()
    t2.start()
 
    t1.join()
    t2.join()

相关问题