Skip to content

Latest commit

 

History

History
21 lines (15 loc) · 500 Bytes

112.md

File metadata and controls

21 lines (15 loc) · 500 Bytes

112 判断月有几天

import calendar
from datetime import date

mydate = date.today()
weekday, days = calendar.monthrange(mydate.year, mydate.month)
print(f'{mydate.year}年-{mydate.month}月的第一天是那一周的第{weekday}\n')
print(f'{mydate.year}年-{mydate.month}月共有{days}\n')

打印结果:

2019-12月的第一天是那一周的第6天

2019-12月共有31天
[上一个例子](111.md) [下一个例子](113.md)