def is_after1(t1, t2):
"""true if t1 follows t2 chronologically"""
if t1.hour > t2.hour:
return True
elif t1.hour == t2.hour:
if t1.minute > t2.minute:
return True
elif t1.hour == t2.hour and t1.minute == t2.minute:
if t1.second > t2.second:
return True
else:
return False
因此,我尝试使用时间作为“Time()”类的对象来运行 is_after 比较。但是,当我运行该函数时,什么也没有发生。这是我的函数以及“time”和“time1”的相关值:
is_after1(time, time1)
time = Time()
time.hour = 12
time.minute = 59
time.second = 30
time1 = Time()
time1.hour = 11
time1.minute = 2
time1.second = 5