Use simple schedule module in python

. 1  Import Schedule
 2  Import Time
 . 3  
. 4  DEF Start ():       # define a function 
. 5      Print ( " **** " )
 . 6  
. 7  
. 8  IF  the __name__ == ' __main__ ' :
 . 9      schedule.every (2) .seconds.do ( start)   # it means every 2 seconds to perform a start function 
10      the while True:   # here is the definition of an infinite loop 
. 11          schedule.run_pending () // each two second interval to check that no
 12 is          the time.sleep (. 1) // this is to allow the program to sleep for a few seconds

 

In addition to performing a function may be the number of seconds interval, the interval may be how many minutes, hours

1, two hours interval

schedule.every(2).hours.do()

2, two minutes interval

schedule.every(2).minutes.do()

Guess you like

Origin www.cnblogs.com/kongbursi-2292702937/p/12166342.html