python分支语句学习之判断一个日期的所在月份有多少天?(题解)
程序员文章站
2022-04-19 17:44:22
判断一个日期的所在月份有多少天?
# coding = utf8
date = '2000-02-08'
s = date.split('...
判断一个日期的所在月份有多少天?
# coding = utf8 date = '2000-02-08' s = date.split('-') year = int(s[0]) month = int(s[1]) day = int(s[2]) # print(year) # print(month) # print(day) days = 0; if month in (1, 3, 5, 7, 8, 10, 12): days = 31 elif month in (4, 6, 9, 11): days = 30 elif month == 2: if (year % 4 == 0 and year % 100 != 0) or (year % 400 == 0): days = 29 else: days = 28 else: print("出错") print(date+'当月天数为'+str(days))
上一篇: 冬季滋润肌肤 必吃12种美白蔬菜
下一篇: iPhone如何关掉屏幕下方的底线