Skip to content

Instantly share code, notes, and snippets.

@lskbr
Created December 27, 2016 13:34
import datetime
def m_int(*args):
return [int(a) for a in args]
def horas_para_segundos(shoras):
t = datetime.time(*m_int(*hs.split(":")))
return t.hour * 3600 + t.minute * 60 + t.second
if __name__ == "__main__":
while True:
try:
hs = input("Digite a hora a converter (hh:mm:ss): ")
segundos = horas_para_segundos(hs)
print(f"Total em segundos: {segundos}")
break
except ValueError as v:
print(f"Você digitou um valor inválido: {v}. Redigite.")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment