I\'m creating a bot that posts every 60 minutes covid numbers, I have it finished but idk how to make it repeat. Any idea? It\'s a little project that I have in mind and it\'s t
You have to use a timer like this one below. (The function refresh refers to itself every hour)
from threading import Timer
def refresh(delay_repeat=3600): # 3600 sec for one hour
# Your refresh script here
# ....
# timer
Timer(delay_repeat, refresh, (delay_repeat, )).start()
Have a look at my runnable refresh graph here to have an idea : How can I dynamically update my matplotlib figure as the data file changes?
You might want to use a scheduler, there is already a built-in one in Python (sched
), read more about it here: https://docs.python.org/3/library/sched.html
You can simply add this statement at the end of the code
sleep(3600)
If you want it to run endlessly, you can do it like this:
while True:
insert your main code here
sleep(3600)