English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
Python has built-in functions, the calendar can handle tasks related to dates. In this example, you will learn to display the calendar for a given date.
To understand this example, you should understand the followingPython programmingTopic:
In the following program, we import the calendar module. The built-in function month() within the module accepts the year and month and displays the calendar for that month.
# Program displays the calendar for the given month and year # Import calendar module import calendar yy = 2014 # year mm = 11 # month # Get user's month and year input # yy = int(input("Enter year: ")) # mm = int(input("Enter month: ")) # Display calendar print(calendar.month(yy, mm))
Output results
November 2014 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
You can change the values of variables yy and mm, and then run it to test this program for other dates.