python 时间下一秒

Posted i勤能补拙

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了python 时间下一秒相关的知识,希望对你有一定的参考价值。

timeStr = input()

#12:23:23

timeList = timeStr.split(":")

h = int(timeList[0])
m = int(timeList[1])
s = int(timeList[2])

s += 1
if s == 60:
m += 1
s = 0
if m == 60:
h += 1
m = 0
if h == 24:
h = 0

print("%.2d:%.2d:%.2d" % (h, m, s))

以上是关于python 时间下一秒的主要内容,如果未能解决你的问题,请参考以下文章