使2个功能同时运行 [英] Make 2 functions run at the same time

查看:57
本文介绍了使2个功能同时运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图同时运行2个功能.

I am trying to make 2 functions run at the same time.

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()

这篇关于使2个功能同时运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆