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
>>> 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
留言
張貼留言