Python Python 月の最終日を取得 hawk 2021-03-02 / 2021-03-07 import calendar print(calendar.monthrange(2021, 3)[1]) # 31 print(calendar.monthrange(2020, 2)[1]) # 29, うるう年 print(calendar.monthrange(2021, 2)[1]) # 28