If the last while loop isn't running, it's because the previous while True
loop never broke.
I suspect it has something to do with your condition current_time == "05:00 / Wednesday"
, which means current_time
is never being set equal to "05:00 / Wednesday"
.
Based on the limited context, I can only suggest two things.
- First off, don't use
while True
loops with only one if statement inside, use the if-condition as your while
loop condition.
- Secondly, you may want to reset
current_time
in your loop. Modify your loop to look something like this:
run_loop = True # will be false when we want our loop to quit
while run_loop:
if current_time == "05:00 / Wednesday":
sub = "link"
driver = webdriver.Chrome(options=opt, executable_path=r'/usr/bin/chromedriver')
Glogin(mail_address, password)
run_loop = False #break us out of the loop
else: #we keep trying to get the time to see if it's 05:00 yet
now = datetime.datetime.now()
current_time = now.strftime("%H:%M / %A")
The above code will continuously check if the time meets your conditions, and then exit appropriately.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…