python periodic doing something

10 is the interval in second...foo is the function to run.

>>> import time, threading
>>> def foo():
... print(time.ctime())
... threading.Timer(10, foo).start()
...




>>> foo()
Thu Dec 22 14:46:08 2011
>>> Thu Dec 22 14:46:18 2011
Thu Dec 22 14:46:28 2011
Thu Dec 22 14:46:38 2011

留言

這個網誌中的熱門文章

Heltec ESP32+OLED+Lora, hardware testing

micro SD card for ESP32, on lolin32 with OLED and heltec 32 lora oled

AIS0. understanding AIS NMEA 0183: How it's coded