Timer:  隔一定时间调用一个函数,如果想实现每隔一段时间就调用一个函数的话,就要在Timer调用的函数中,再次设置Timer。Timer是Thread的一个派生类

 

 1 import threading
 2 import time
 3 
 4 def hello(name):
 5     print "hello %s\n" % name
 6 
 7     global timer
 8     timer = threading.Timer(2.0, hello, ["Hawk"])
 9     timer.start()
10 
11 if __name__ == "__main__":
12     timer = threading.Timer(2.0, hello, ["Hawk"])
13     timer.start()

 

相关文章:

  • 2022-12-23
  • 2021-11-15
  • 2022-01-07
  • 2021-07-17
  • 2021-10-07
  • 2021-12-19
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-06-20
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案