I am trying to compare the current time with a value given as text string. I don't know how to bring things to a common denominator, because I feel that the time obtained is not quite the same as a simple text string, even if it looks so when printing.
Test code:
import time
import datetime
def GetTimeAndWeekday(data):
datetime_now = datetime.datetime.now()
if data == "hms":
time_now = datetime.time(datetime_now.hour, datetime_now.minute, datetime_now.second)
return time_now
elif data == "hm":
time_now = datetime.time(datetime_now.hour, datetime_now.minute)
return time_now
return datetime_now
data = "hm"
found = GetTimeAndWeekday(data)
print found # for "hm" this gives current time in HH:MM:00 format, say 05:29:00
# I want to do something like this logic:
if found == "05:29:00":
print "the same"
else:
print "not the same"
How can I do that logic ?