Some useful python module

calendar: display the number of days specified month

calendar

The number of days for each month is not the same as the month has 31 days 1,3,5 and so on, and so on 4,6,9 month has 30 days, not to mention the number of days more special in February.

So how to quickly and effectively get the total number of days a certain period, the more trouble .Python provides us with a built-in module to solve this problem.

import calendar
print(calendar.monthrange(2019,2)[1])   # 28
print(calendar.monthrange(2008,2)[1])   # 29

 

Guess you like

Origin www.cnblogs.com/yaraning/p/11283302.html