DEV Community

Hasan Sajedi
Hasan Sajedi

Posted on

Display calendar with python

Python has a built-in function, 'calendar' to work with date related tasks.
You will learn to display the calendar of a given date with below example.


import calendar

yy = 2018
mm = 8

print(calendar.month(yy, mm))
Enter fullscreen mode Exit fullscreen mode

In the program top, we import the calendar module. The built-in function month() inside the module takes in the year and the month and displays the calendar for that month of the year.

Output:

    August 2018
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
Enter fullscreen mode Exit fullscreen mode

Top comments (0)