Python中的定时器threading.Timer

  • Timer:定时调用函数

例子1:

import threading
import time

def hello(name):
    print ("hello %s\n" ) % name
    global timer
    timer = threading.Timer(2.0, hello, ["Hawk"])
    timer.start()

if __name__ == "__main__":
    timer = threading.Timer(2.0, hello, ["Hawk"])   ##每隔两秒调用函数hello
    timer.start()
 

 

posted @ 2019-06-10 14:59  小鳄鱼DL  阅读(16806)  评论(1编辑  收藏  举报