On this page
calendar.monthcalendar
Prev: calendar.Month | Up: calendar | Next: calendar.monthrange
Rel: calendar.calendar, calendar.Calendar, calendar.Day, calendar.firstweekday
Ref: docs.python.org — calendar.monthcalendar
Tags: #public #python3 #stdlib #calendar
Import
import calendar
from calendar import monthcalendar
Signature & Overview
calendar.monthcalendar(year, month)
Return a matrix representing a month's calendar.
Usage
import calendar
matrix = calendar.monthcalendar(2026, 12)
assert all(len(week) == 7 for week in matrix)
Gotchas
- Padding days outside the month are
0: Don't pass0directly todatetime.date(y, m, d)without filtering.
REPL Inspect
from calendar import monthcalendar
help(monthcalendar)
Linked from
Related notes
- tuts/python3/stdlib_module/calendar/Month_class Linked here; links to this page; shared tags: #calendar, #stdlib
- tuts/python3/stdlib_module/calendar/monthrange Linked here; links to this page; shared tags: #calendar, #stdlib
- tuts/python3/stdlib_module/calendar/calendar Linked here; shared tags: #calendar, #stdlib
- tuts/python3/stdlib_module/calendar/Calendar_class Linked here; shared tags: #calendar, #stdlib
- tuts/python3/stdlib_module/calendar/Day Linked here; shared tags: #calendar, #stdlib
- tuts/python3/stdlib_module/calendar/firstweekday Linked here; shared tags: #calendar, #stdlib
- tuts/python3/stdlib_module/calendar links to this page; shared tags: #stdlib
- tuts/python3/stdlib_module/calendar/HTMLCalendar shared tags: #calendar, #stdlib
- tuts/python3/stdlib_module/calendar/IllegalMonthError shared tags: #calendar, #stdlib
- tuts/python3/stdlib_module/calendar/IllegalWeekdayError shared tags: #calendar, #stdlib