q66262 发表于 2018-8-10 13:12:39

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

  '''
  time: 12:00:00 plus 1 second
  time result : 12:00:01
  '''
  t1 =input("pls input the time: ")
  list1 = t1.split(":")
  hour = eval(list1)
  minute = eval(list1)
  second = eval(list1)
  if hour > 24 or minute > 59 or second > 59 :
  print("pls input the right format")
  exit()
  if second < 59 :
  print(&quot;%d:%d:%d&quot;%(hour,minute,second + 1))
  else:
  if minute < 59 :
  print(&quot;%d:%d:00&quot;%(hour,minute + 1))
  else:
  if hour <23 :
  print(&quot;%d:00:00&quot;%(hour + 1))
  else:
  print(&quot;00:00:00&quot;)
页: [1]
查看完整版本: python计算当前输入时间的下一秒