The way you have it now, your rr while loop will continually run and update Tomorrow_Date
, and when the day rolls over, it will update before it has a chance to be compared to Today_Date
. You should set both Today_Date
and Tomorrow_Date
outside that loop, and only update them when the dates change.
This should do the trick:
If you want two loops for other reasons:
import datetime
r = True
while r:
rr = True
Tomorrow_Date = datetime.date.today() + datetime.timedelta(days=1)
while rr:
if datetime.date.today() >= Tomorrow_Date:
print("Yes")
rr = False
Or as a single loop:
import datetime
r = True
Tomorrow_Date = datetime.date.today() + datetime.timedelta(days=1)
while r:
if datetime.date.today() >= Tomorrow_Date:
print("Yes")
Tomorrow_Date = datetime.date.today() + datetime.timedelta(days=1)
It might be a good idea to add a time.sleep() in to slow down the loops, depending on how accurate you need to be also.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…