I have an if statement below that I want to execute at exactly 11:45 am every single day. The problem is, when I run my Python script, result.tm_min
and result.tm_hour
are static, holding whatever time it was when I started the script in th first place. I need some way for these values to change in real-time with the clock. So when the time changes from 11:44 to 11:45, result.tm_min
also changes from 44 to 45, allowing for the below if statement to execute. If I could get any help with this, that would be awesome.
I'm currently using the time and datetime libraries for this.
if result.tm_hour == 11:
if result.tm_min == 45:
post_number = random.randint(1, 5)
noun_number = random.randint(1, noun_expand_count)
verb_number = random.randint(1, verb_expand_count)
noun_file = open("nouns.txt", "r")
get_noun_line = noun_file.readlines()
new_noun = get_noun_line[noun_number].strip()
noun_file.close()
verb_file = open("verbs.txt", "r")
get_verb_line = verb_file.readlines()
new_verb = get_verb_line[verb_number].strip()
verb_file.close()
post_file = open("things_to_do.txt", "r")
get_post_line = post_file.readlines()
new_post = get_post_line[post_number].strip()
post_file.close
message = "@joerogan Hello Joe, today's top two priorities are to:", new_post, new_verb, new_noun
print(message)
#api.update_status(message)
Aucun commentaire:
Enregistrer un commentaire