Python calculate the number of days per month
The following code block is calculated by importing calendar days of each month:
# Filename : test.py # author by : www.w3big.com import calendar monthRange = calendar.monthrange(2016,9) print(monthRange)
Execute the above code output results:
(3, 30)
The output is a tuple, the first element of the investigation is the first day of the month corresponding to the day of the week (0-6), the second element is the number of days of the month. Examples of the above output means the first day of September 2016 is Thursday, the monthly total of 30 days.