티스토리 뷰

프로그래밍

Python 시간 변환

warpmemory 2020. 3. 6. 21:59
>>> import time
>>> from datetime import datetime

>>> time.time()
1345556352.4712839

>>> time.localtime()
(2012, 8, 21, 22, 39, 12, 1, 234, 0)

>>> time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(time.time()))
'2012-08-21 22:39:12'

>>> int(time.mktime(datetime(2012, 8, 21, 22, 34, 34).timetuple()))
1345556074

>>> datetime(*time.strptime("2012-08-21 22:34:34", "%Y-%m-%d %H:%M:%S")[0:6])
datetime.datetime(2012, 8, 21, 22, 34, 34)
댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
페이지
«   2025/01   »
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31
글 보관함