首页  >  问答  >  正文

python同时执行两个函数

我现在自定义了两个函数

def test():

while True:
    ...
    ...

def test1():

while True:
    ...
    ...

这两个函数都是一个无限循环的两个函数,我现在想让这两个函数在同一个PY文件中去同时执行,不知道大佬们有什么好的解决方法呢。新手求教。

欧阳克欧阳克2675 天前929

全部回复(1)我来回复

  • 为情所困

    为情所困2017-06-22 11:54:20

    多线程 threading

    import threading
    
    threading.Thread(target= test).start()
    threading.Thread(target=test1).start()

    回复
    0
  • 取消回复