My Coding > Programming language > Python > Python libraries and packages > Calendar

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:

Calendar for the 2004 year
Calendar for the 2004 year
The full annual calendar for the year 2004 printed with the Python library calendar.
Original image: 825 x 766

This is our short video on how to use it:


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

Last 10 artitles


9 popular artitles

© 2020 MyCoding.uk -My blog about coding and further learning. This blog was writen with pure Perl and front-end output was performed with TemplateToolkit.