w3resource

Python Calendar Module : monthdayscalendar() method

monthdayscalendar() method

The monthdayscalendar() method is used to get a list of the weeks in the month of the year as full weeks. Weeks are lists of seven-day numbers.

Syntax:

monthdayscalendar(year, month)

Parameters:

Name Description Required /
Optional
Type
year Year for which the calendar should be generated. Required Number
month Month for which the calendar should be generated. Required Number

Example of monthdayscalendar() method

import calendar
cal= calendar.Calendar()
print(cal.monthdayscalendar(2016, 5))

Output:

[[0, 0, 0, 0, 0, 0, 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, 0, 0, 0, 0, 0]]

Previous: monthdays2calendar()
Next: yeardatescalendar()

Test your Python skills with w3resource's quiz



Become a Patron!

Follow us on Facebook and Twitter for latest update.

It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.

https://198.211.115.131/python/module/calendar/monthdayscalendar.php