[Python] 파이썬으로 시간, 분, 초 변환하기


[Python] 파이썬으로 시간, 분, 초 변환하기

파이썬을 사용하여 시간, 분, 초를 변환하는 간단한 코드 입니다! 1. 시간 >> 초 def time_to_seconds(hours): total_seconds = hours * 3600 return total_seconds # 사용자로부터 시간을 입력받음 hours = int(input("시간을 입력하세요: ")) # 시간을 초로 변환하여 출력 total_seconds = time_to_seconds(hours) print("입력한 시간은 총 {} 초입니다.".format(total_seconds)) 실행 결과 시간을 입력하세요: 2 입력한 시간은 총 7200 초입니다. 2. 시간, 분 >> 초 def time_to_seconds(hours, minutes): total_seconds = hours * 3600 + minutes * 60 return total_seconds # 사용자로부터 시간과 분을 입력받음 hours = int(input("시간을 입력하세요: ")) minut...


#파이썬

원문링크 : [Python] 파이썬으로 시간, 분, 초 변환하기