python 线程定时器

2019-06-18  本文已影响0人  你说你要一场

基本思想是:函数中使用线程定时器函数调用自己。
当然,用户自己在函数外使用线程定时器函数起个头。

>>> 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()
上一篇 下一篇

猜你喜欢

热点阅读