calendar module: Module is used to display the calendar.
month(): It will display the calendar of specified month in an year with pre-defined structure.
import calendar
year=2018
month=5
cal = calendar.month(year,month)
print(cal)
- By default, every week starts with MONDAY.
- To start printing calendar from another Week day, we use TextCalendar object functionality as follows.
- TextCalendar is a class belongs to “calendar” module.
import calendar
year=2018
month=5
cal = calendar.TextCalendar(calendar.SUNDAY)
data = cal.formatmonth(year,month)
print(data)
Printing months:
import calendar
for name in calendar.month_name:
print(name)
Printing days:
import calendar
for name in calendar.day_name:
print(name)