Python code
Python code
I need a couple of programs in python. First one is very simple. Just need to print a msg at the same time Monday -Friday. Second is a little more complex. Wondering if anyone can help. TIA
-
Bozo Verified
- Owner
- Posts: 9,438
- Joined: Aug 31 2004, 13:06
- Handle: Bozo The Clown
- Real Name: James
- Antenna: Monkey Made MM9
- Radio: General Lee Radio
- Contact:
@JetSetter --- Sorry I missed this. To create a Python program that prints a message at the same time Monday to Friday, you can use the schedule library. The complete code for the program is below:
First, install the schedule library if you haven't already:
Now, here is the Python script:
This script schedules the job() function to run at 10:00 AM from Monday to Friday. You can change the time "10:00" to any desired time. The script will continuously check for the scheduled time and run the job() function when it matches.
First, install the schedule library if you haven't already:
Code: Select all
pip install schedule
Code: Select all
import schedule
import time
from datetime import datetime
def job():
print("This is your scheduled message.")
# Schedule the job to run at the same time Monday to Friday
schedule.every().monday.at("10:00").do(job)
schedule.every().tuesday.at("10:00").do(job)
schedule.every().wednesday.at("10:00").do(job)
schedule.every().thursday.at("10:00").do(job)
schedule.every().friday.at("10:00").do(job)
# Keep the script running
while True:
schedule.run_pending()
time.sleep(1)