본문 바로가기
카테고리 없음

python 실행시간 찍기 clear_output

by Z@__ 2020. 10. 4.
반응형

# time & clear output library
import time
from IPython.display import clear_output

# get KST time zone library
import datetime
from pytz import timezone, utc

# start_time = utc.localize(now).astimezone(KST)
# ts = time.time()
# time.strftime('%H:%M:%S', time.gmtime(12345))

def KST_time():
    now = datetime.datetime.utcnow()
    KST = timezone('Asia/Seoul')
    KST.localize(now)
    return utc.localize(now).astimezone(KST)

start_time = KST_time()
ts = time.time()

while True:
    time.sleep(1)
    temp = time.time() - ts
    h = str(int(temp // 3600)).zfill(2)
    temp = temp % 3600
    m = str(int(temp // 60)).zfill(2)
    temp = temp % 60
    s = str(int(temp)).zfill(2) 
    clear_output(wait=True)
    print("[start time]", start_time)
    print("[play time]",h,":",m,":",s)

 

반응형

댓글