CBRT has been

Python code

Need some help fixing a computer problem, or just want to share a link to a program? Do it hear... From the PC to the CB!!!
Post Reply
User avatar
Deleted User 30222

Python code

#408982

Post 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
User avatar
Bozo
Verified
Owner
Owner
Posts: 9,437
Joined: Aug 31 2004, 13:06
Handle: Bozo The Clown
Real Name: James
Antenna: Monkey Made MM9
Radio: General Lee Radio
Contact:

#412010

Post 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.
Image

Donate here


Post Reply