반응형
# 올해 중 오늘의 일수 구하는 예제
import calendar
from datetime import date
today = date.today().isoformat().split('-')
yeardays = 0
for i in range(int(today[1])):
if i > 0:
yeardays += calendar.monthrange(int(today[0]),i)[1]
yeardays += int(today[2])
print("Today is the", yeardays, "days of the year")
반응형
'Programming > Python' 카테고리의 다른 글
[Python] TensorFlow(2.14) Installation (Ubuntu, Nvidia GPU, + PyTorch) (0) | 2024.02.11 |
---|---|
[Python] random 모듈 사용 예제 (0) | 2023.11.08 |
[Python] TensorFlow(2.13) Installation (Ubuntu, Nvidia GPU, + PyTorch) (0) | 2023.07.26 |
[Python] Jupyter Notebook Remote Configuration (0) | 2023.01.31 |
[Python] TensorFlow(2.11) Installation (Ubuntu, Nvidia GPU, + PyTorch) (1) | 2022.11.10 |