Python calculates the number of days in the month of the specified year and month and the day of the week on the first day of the month

Python calculates the number of days in the month of the specified year and month and the day of the week on the first day of the month

To calculate the number of days in a specified year and month, use the monthrange method of the calendar module.

import calendar
print(calendar.monthrange(2022, 3))  # (1,31),其中1是周二,2是周三。。。

Returns a tuple of two integers, the first is the day of the week for the first day of the month (calculated as Monday is 0), and the second is the day of the month.

Thank you for your support. Your one-click three-connection is the biggest driving force for Ganggang students!

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324321902&siteId=291194637