Page 1 of 1

Python code

Posted: May 08 2022, 20:15
by Deleted User 30222
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

Re: Python code

Posted: Jun 28 2024, 18:06
by Bozo
@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:

Code: Select all

pip install schedule
Now, here is the Python script:

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)
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.