2、 Code practice :
import schedule# introduce schedule library
import time# introduce time library
def eating():# Define a task to perform
print(' Your mother told you to go home for dinner ')
def AA(name):# Define a task to perform
print(name+'it is time up')
name=' Xiao Ming '
schedule.every(5).seconds.do(AA,name)# Define interval 5 Run the code every second
schedule.every(10).minutes.do(eating)# Define interval 10 Run the code every minutes
schedule.every().hour.do(eating)# Define the code to run every other hour
schedule.every().day.at("11:30").do(eating)# Defined in daily 15:30 Run code
schedule.every().monday.at("11:30").do(eating)# Defined on every Monday 15:30 Run code
while True:# Keep the program running
schedule.run_pending()# Run all the tasks that can be run
time.sleep(10)# Rest after running 10 Second, check whether there are tasks that can be run
Running results :