Would I be able to get datetime to tell me if the time is in range of 12:00 to 1300
I have tried variations of things like:
import datetime
current_time = datetime.datetime.now().time()
if current_time from 12:00 and 13:00:
print("In time")
Would I be able to get datetime to tell me if the time is in range of 12:00 to 1300
I have tried variations of things like:
import datetime
current_time = datetime.datetime.now().time()
if current_time from 12:00 and 13:00:
print("In time")
Compare against other
datetime.time()
objects:This uses comparison chaining, the above is basically the same expression as:
but the
current_time
expression is evaluated just once.I gave
datetime.time()
just the hour component; the minutes then default to0
: