본문 바로가기

Algorithm Problems/기타

[백준/Python] 16170번: 오늘의 날짜는?

문제

https://www.acmicpc.net/problem/16170

 

16170번: 오늘의 날짜는?

지금 시각을 UTC+0(세계 표준시)을 기준으로 나타냈을 때의 연도, 월, 일을 한 줄에 하나씩 순서대로 출력한다.

www.acmicpc.net


문제 요약

현재 시각을 연도, 월, 일을 한 줄에 하나씩 출력한다.


코드

import datetime

today = datetime.date.today()

year = today.year
month = today.month
day = today.day

print(year)
print(month)
print(day)

코드 설명

1. datetime 모듈을 import하고,

today 인스턴스를 생성한다.

 

2. today 인스턴스의 필드를 이용하여 형식에 맞게 출력한다.