Thursday 14 July 2016

Python: Calendar: monthrange: get number of days in month

calendar.monthrange(year, month)
Return first day of the month and number of days in given month in given year.
>>> import calendar
>>> calendar.monthrange(2015,11)
(6, 30)
>>> calendar.monthrange(2015,12)
(1, 31)


Previous                                                 Next                                                 Home

No comments:

Post a Comment