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

留言

這個網誌中的熱門文章

Meshtastic 03 adding GPS on TTGO lora32 V2

GeoSetter how to add geotag on to pictures, and export to google earth as kmz

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