#比如每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()

 


 

相关文章:

  • 2023-04-10
  • 2022-12-23
  • 2022-12-23
  • 2023-03-19
  • 2021-06-26
  • 2023-03-19
  • 2023-04-11
猜你喜欢
  • 2021-08-22
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-06-10
相关资源
相似解决方案