R
R
renthxz2020-12-02 13:50:38
Python
renthxz, 2020-12-02 13:50:38

How can I make my function run at a specific time?

I need my function to start at exactly 16:00.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
C
Chaka YS, 2020-12-02
@Chaka_1

You can do it via schedule, read how to use it, it's incredibly easy to implement.
Or you can do it through the datetime check, almost the same as option 1, but easier.
One minus of all this - the script must be enabled on a permanent basis, or use the option from 1 answer.

P
Popou, 2020-12-03
@Popou

There is one dumb way to
create a main.pyw file

def your_func():
    pass

import datetime

now = datetime.datetime.now()

while True:
    if(now.strftime("%H:%M")=="16:00"):
        your_func()

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question