본문 바로가기

Python

Formatting time

자주 쓰는 method라서...

 

import datetime
def format_time():
    t = datetime.datetime.now()
    s = t.strftime('%Y-%m-%d %H:%M:%S.%f')
    return s[:-3]

current_time = format_time()

'Python' 카테고리의 다른 글

List with *  (0) 2020.08.12
[Python] lambda vs list comprehension  (0) 2019.01.18
[Python] Virtual Environment  (0) 2019.01.09
Xing API] Real time data subscribe  (0) 2016.03.03
Xing API] Connection and login  (0) 2016.03.02