프로그래밍 언어/Python

파이썬에서 Microsecond(마이크로초) 단위까지 시간 출력하기

fdsa_000 2017. 10. 17. 21:08

from datetime import datetime


print(datetime.utcnow().strftime('%Y-%m-%d %H:%M:%S.%f'))



1
2
3
from datetime import datetime
 
print(datetime.utcnow().strftime('%Y-%m-%d %H:%M:%S.%f'))
cs


1
2
3
4
5
6
7
[user@vm ~]$ cat date.py
from datetime import datetime
 
print(datetime.utcnow().strftime('%Y-%m-%d %H:%M:%S.%f'))
[user@vm ~]$
[user@vm ~]$ python date.py
2017-10-17 12:06:03.552259
cs


  • 참고 사이트

Format a datetime into a string with milliseconds, https://stackoverflow.com/questions/7588511/format-a-datetime-into-a-string-with-milliseconds