Created
December 27, 2016 13:34
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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