{"id":25999,"date":"2021-12-07T18:06:42","date_gmt":"2021-12-07T12:36:42","guid":{"rendered":"https:\/\/python-programs.com\/?p=25999"},"modified":"2021-12-08T20:38:09","modified_gmt":"2021-12-08T15:08:09","slug":"python-program-for-calendar-formatmonth-method-with-examples","status":"publish","type":"post","link":"https:\/\/python-programs.com\/python-program-for-calendar-formatmonth-method-with-examples\/","title":{"rendered":"Python Program for calendar formatmonth() Method with Examples"},"content":{"rendered":"

Calendar Module:<\/strong><\/p>\n

The calendar module allows you to output calendars like a program and includes extra calendar-related operations. Calendar module functions and classes make use of an idealized calendar, the current Gregorian calendar extended in both directions indefinitely.<\/p>\n

formatmonth() Method:<\/strong><\/p>\n

To obtain a month’s calendar in a multi-line string, use the formatmonth() method.<\/p>\n

To generate plain text calendars, class calendar.TextCalendar(firstweekday=0) can be used.The formatmonth() method is one of the TextCalendar instance’s methods.<\/p>\n

Syntax:<\/strong><\/p>\n

formatmonth(year, month, width=0, lines=0)<\/pre>\n

Parameter Values:<\/strong><\/p>\n

year:<\/strong> This is required. It is a number. It is the year for which the calendar should be created.<\/p>\n

month:<\/strong> This is required. It is a number. It is the month for which the calendar should be created.<\/p>\n

width:<\/strong> This is Optional. It is a number. It Specifies the width of the centered date columns. The default value is zero.<\/p>\n

lines:<\/strong> This is Optional. It is a number. It Specifies the number of lines that each week will use. The default value is zero.<\/p>\n

Return Value:<\/strong> It returns a calendar for the month.<\/p>\n

Program for calendar formatmonth() Method with Examples in Python<\/h2>\n