#输入年份和月份,用Python判断这年这月有多少天

时间:2025-02-09 22:11:57

#日常笔记

while True:
    def isLeep(y):
        result = y%4==0 and y%100!=0 or y%400==0
        return result
    days = [0,31,28,31,30,31,30,31,31,30,31,30,31]
    year = int(input("年份:"))
    manth = int(input("月份:"))
    if isLeep(year):
        days[2] = 29
    print("天数:",days[manth])

转载于:/u/4138052/blog/3053451