基本思想是:函数中使用线程定时器函数调用自己。
当然,用户自己在函数外使用线程定时器函数起个头。
>>> import threading
>>> import time
>>> def hello(name):
... print("hello",name)
... global timer
... timer = threading.Timer(2.0, hello, ['hoho'])
... timer.start()
自己起个头:
>>> timer = threading.Timer(2.0, hello, ['hoho'])
>>> timer.start()
网友评论