Soldato
- Joined
- 22 Nov 2007
- Posts
- 4,209
Hi All
I'm having trouble getting the following code to execute, it works fine with the set_time variable but with time_to_set, nothing happens. What am i doing wrong please?
I'm having trouble getting the following code to execute, it works fine with the set_time variable but with time_to_set, nothing happens. What am i doing wrong please?
Code:
import datetime
dt=datetime
#set_time=str(dt.time(14,19))[0:5]
time_to_set=datetime.datetime(year=2022, month=12, day=1, hour=14, minute=19, second=0, microsecond=0, tzinfo=None, fold=0)
timenow=dt.datetime.now().time()
time=False
while not time:
timenow=str(dt.datetime.now().time())[0:5]
# print(timenow)
if timenow==time_to_set:
print("yeeehaaa")
time=True
break
else:
print("naaaaa")