w3resource

Python TextCalendar Module: monthrange() method

monthrange() method

The monthrange() method is used to get weekday of first day of the month and number of days in month, for the specified year and month.

Syntax:

monthrange(year, month)

Parameters:

Name Description Required /
Optional
Type
year Year to get weekday of the first day of the month and number of days in month. Required Number
month Month to get weekday of the first day of the month and number of days in a month. Required Number

Example of monthrange() method

import calendar
print(calendar.monthrange(2016,5))

Output:

(6, 31)

Previous: weekheader()
Next: monthcalendar()

Test your Python skills with w3resource's quiz



Follow us on Facebook and Twitter for latest update.