原文:https://blog.csdn.net/l_d_56/article/details/84832198

输入一个时间,获取这个时间的下一秒

PS:下面代码使用于 python 2.7

time1 = raw_input("输入一个时间[HH:MM:SS]:")
time1List = time1.split(":")
time1List = [int(x) for x in time1List]

shi = time1List[0]
fen = time1List[1]
miao = time1List[2]

if miao == 59:
    miao = 0
    fen += 1
    if fen == 60:
        fen = 0
        shi += 1
        if shi == 24:
            shi = 0
else:
    miao += 1
print '输出下一秒的时间为:%02d:%02d:%02d' % (shi, fen, miao)

输出:

输入一个时间[HH:MM:SS]:11:03:00
输出下一秒的时间为:11:03:01

Process finished with exit code 0

 

相关文章:

  • 2021-06-20
  • 2021-07-13
  • 2021-08-13
  • 2021-12-30
  • 2022-12-23
  • 2021-09-09
  • 2022-12-23
  • 2021-12-03
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-02-18
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-05-20
相关资源
相似解决方案