In [1]:
import calendar

In [2]:
print(calendar.monthrange(2019, 1))


(1, 31)

In [3]:
print(calendar.monthrange(2019, 1)[1])


31

In [4]:
print(calendar.monthrange(2019, 2)[1])


28

In [5]:
print(calendar.monthrange(2020, 2)[1])


29

In [6]:
print(calendar.monthlen(2019, 1))


31

In [7]:
print(calendar.__all__)


['IllegalMonthError', 'IllegalWeekdayError', 'setfirstweekday', 'firstweekday', 'isleap', 'leapdays', 'weekday', 'monthrange', 'monthcalendar', 'prmonth', 'month', 'prcal', 'calendar', 'timegm', 'month_name', 'month_abbr', 'day_name', 'day_abbr', 'Calendar', 'TextCalendar', 'HTMLCalendar', 'LocaleTextCalendar', 'LocaleHTMLCalendar', 'weekheader']

In [8]:
print('monthlen' in calendar.__all__)


False

In [9]:
print('monthrange' in calendar.__all__)


True