mercredi 23 septembre 2020

Execute function X amount of times between two dates, how would I do it?

If I was able to execute a function a (user-specified) amount of time between two dates, how would I do it?

Am I on the right track?

from datetime import date, datetime
from upload import *

current_time = datetime.utcnow()
start_time = datetime.time.hour(17)
end_time = datetime.time.hour(20)

imageposts = []
post_limit = 0

for imagepost in imageposts:
    if start_time <= current_time & current.time <= end_time & post_limit <= 3:
        try:
            upload()
            postlimit += 1
        except:
            print('Current time is not between times')

Aucun commentaire:

Enregistrer un commentaire