파이썬 사용자 함수
DB CAFE
thumb_up 추천메뉴 바로가기
- DBA { Oracle DBA 명령어 > DBA 초급 과정 > DBA 고급 과정 }
- 튜닝 { 오라클 튜닝 목록 }
- 모델링 { 데이터 모델링 가이드 }
시간 초를 시:분:초로 계산(sec2time)[편집]
틀:투명 타이틀 <source lang=python> def sec2time(sec, n_msec=3):
Convert seconds to 'D days, HH:MM:SS.FFF' if hasattr(sec,'__len__'): return [sec2time(s) for s in sec] m, s = divmod(sec, 60) h, m = divmod(m, 60) d, h = divmod(h, 24) if n_msec > 0: pattern = '%%02d:%%02d:%%0%d.%df' % (n_msec+3, n_msec) else: pattern = r'%02d:%02d:%02d' if d == 0: return pattern % (h, m, s) return ('%d days, ' + pattern) % (d, h, m, s)
</python>