Python Glossary Русский

all Python 3calendarfunction

calendar.calendar()

printing calendars

Returns a calendar for a whole year as one multi-line string, three months per row by default.

Syntax

calendar.calendar(theyear, w=2, l=1, c=6, m=3)

The function prints nothing — prcal() prints the same thing with the same parameters. m sets months per row, w the day column width, c the gap between months. The first weekday comes from the global setfirstweekday() setting. from calendar import calendar shadows the module name with the function — a common mix-up.

Examples

import calendar
text = calendar.calendar(2024)
print(text.splitlines()[0].strip())  # → 2024
print(len(text.splitlines()), len(calendar.calendar(2024, m=4).splitlines()))  # → 35 26

See also

Open in the full glossarydocs.python.orgReport an inaccuracy