python计算当前输入时间的下一秒

2020-01-09 21:04:40 浏览数 (1)

''' time: 12:00:00 plus 1 second time result : 12:00:01 '''

t1 = input("pls input the time: ") list1 = t1.split(":") hour = eval(list1[0]) minute = eval(list1[1]) second = eval(list1[2]) if hour > 24 or minute > 59 or second > 59 : print("pls input the right format") exit() if second < 59 : print("%d:%d:%d"%(hour,minute,second 1)) else: if minute < 59 : print("%d:%d:00"%(hour,minute 1)) else: if hour < 23 : print("%d:00:00"%(hour 1)) else: print("00:00:00")

0 人点赞