#比如每3秒打印一次helloworld:
from threading import Timer def printHello(): print "Hello World" t = Timer(60, printHello) t.start() if __name__ == "__main__": printHello()
这里的运行环境是:python2.7
threading模块中的Timer能够帮助实现定时任务,而且是非阻塞的。每隔60秒执行一次!
再比如:
比如3秒后打印helloworld:
from threading import Timer
def printHello(): print "hello world" Timer(3, printHello).start()