Calendar

Calendar - a Python library from the standard installation. Very simple with very basic results, but can be convenient when you need to print or have a text version of the calendar for any month year or other time selection. This library has a lot of formatting tools for different selections.

Import the library and define the Year and Month for printing


import calendar
Y=2004
M=10

Now one can print them in a calendar format and it is not necessary to use complicated libraries to select or generate them these days.

For example, printing month:


print(calendar.month(Y,M))
 #   October 2004
#Mo Tu We Th Fr Sa Su
  #           1  2  3
 #4  5  6  7  8  9 10
#11 12 13 14 15 16 17
#18 19 20 21 22 23 24
#25 26 27 28 29 30 31

To print a calendar for a year, use:


print(calendar.calendar(Y))

The result will look like the following:

The full annual calendar for the year 2004 printed with the Python library calendar.
Calendar for the 2004 year

The full annual calendar for the year 2004 printed with the Python library calendar.

This is our short video on how to use it:


Published: 2024-07-24 09:53:57
Updated: 2024-07-24 10:19:17