Below is the code and above is the error have specified import datetime in the begging Below is the code and above is the error have specified import datetime in the begging
---------------------------------------------------------------------------
NameError Traceback (most recent call last)
Cell In [6], line 3
1 while True:
----> 3 if (datetime.today().weekday() != 6) & (date.today().weekday() != 5):
5 hours = [9,10,11,12,13,14,15]
6 minutes = [0,15,30,45]
NameError: name 'datetime' is not defined
while True:
if (date.today().weekday() != 6) & (date.today().weekday() != 5):
hours = [9,10,11,12,13,14,15]
minutes = [0,15,30,45]
for hour in hours:
for minute in minutes:
schedule_time = datetime.time(hour,minute)
if (schedule_time >= datetime.time(9,15)) & (schedule_time <= datetime.time(15,15)):
schedule.every().day.at(str(schedule_time)).do(job)
while True:
schedule.run_pending()
sleep(300)
else:
now_datetime = datetime.now()
next_datetime = datetime.combine(date(now_datetime.year,now_datetime.month,now_datetime.day + 1), time(9,15))
sleep((next_datetime - now_datetime).seconds)
need solution for the above error