파이썬/datetime 활용
python(vscode)/남은 시간계산/시간 계산하기/datetime
gongdol
2023. 10. 3. 16:30
300x250
현재시간부터 목표시간까지 남은시간 계산하는 코드를 작성해보자.
1. 코드작성
1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
from datetime import datetime
def time_calculation():
now = datetime.now()
print("현재시간 = {}".format(now))
choose_time = now.replace(hour=19, minute=0, second=0, microsecond=0)
print("특정시간 = {}".format(choose_time))
print("남은시간 (현재시간 - 특정시간) = {}".format(choose_time-now))
time_calculation()
|
cs |
2. 결과
300x250