Python to run a piece of code at a defined time every day
问题 In my python program, I would like it to run a piece of code at a pre-defined time every weekday, let say 2pm Mon - Fri. How may I do it please? 回答1: You can use "schedule" library to install, on terminal enter: pip install schedule here is an example of the code you want: #!/usr/bin/python import schedule import time def job(): print("I am doing this job!") schedule.every().monday.at("14:00").do(job) schedule.every().tuesday.at("14:00").do(job) schedule.every().wednesday.at("14:00").do(job)