whois

Python 남은 시간 구하기 본문

Development/Python

Python 남은 시간 구하기

HongJun Choi 2018. 4. 18. 22:09

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
import datetime
import math
import time
 
while True:
    datetime.datetime.now()
    start_time = datetime.datetime.now()
    end_time = datetime.datetime(2018515)
    how_long = end_time - start_time
    days = how_long.days
    hours = how_long.seconds // 3600
    minutes = how_long.seconds // 60 - hours * 60
    seconds = how_long.seconds - hours * 3600 - minutes * 60
 
    print('{}일 {}시간 {}분 {}초 남았습니다.'.format(days, hours, minutes, seconds))
    time.sleep(1)
cs




















3.6.4 버전에서 테스트 하였습니다.


Comments