gpt4 book ai didi

python - 如何同时运行多个功能?

转载 作者:IT老高 更新时间:2023-10-28 21:46:47 24 4
gpt4 key购买 nike

我正在尝试同时运行 2 个函数。

def func1():
print('Working')

def func2():
print('Working')

func1()
func2()

有人知道怎么做吗?

最佳答案

这样做:

from threading import Thread

def func1():
print('Working')

def func2():
print("Working")

if __name__ == '__main__':
Thread(target = func1).start()
Thread(target = func2).start()

关于python - 如何同时运行多个功能?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2957116/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com