您的位置:首页技术文章
文章详情页

python同时执行两个函数

【字号: 日期:2022-06-28 08:08:57浏览:45作者:猪猪

问题描述

我现在自定义了两个函数

def test():

while True: ... ...

def test1():

while True: ... ...

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

问题解答

回答1:

多线程 threading

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

标签: Python 编程
相关文章: