calendar.monthcalendar()
calendar.monthcalendar() is a Python function in the Calendar Module category. Returns a matrix (list of weeks) representing a month. Each week has 7 days (0=outside month). The syntax is calendar.monthcalendar(year, month). Returns: List of weekly lists. A typical example: calendar.monthcalendar(2026, 6)
# [[1,2,3,4,5,6,7], [8,...], ...]. A close sibling is calendar.TextCalendar(), which creates a calendar that generates plain text calendars. A close sibling is calendar.HTMLCalendar(), which creates a calendar that generates HTML calendars. A close sibling is calendar.isleap(), which returns True if the year is a leap year. A close sibling is calendar.leapdays(), which returns the number of leap years in the range [y1, y2). More about this category: Calendar functions — TextCalendar, isleap, monthrange, weekday. For a broader walkthrough, read the Calendar Module guide. Related Calendar Module entries: calendar.TextCalendar(), calendar.HTMLCalendar(), calendar.isleap(), calendar.leapdays(), calendar.weekday(), calendar.monthrange(). This page is part of the free Python Reference documentation covering 978+ functions, methods, and modules with examples and parameter details.