标签:day inpu 某月 判断 python练习 不能 class == pytho
‘‘‘
输入某年某月某日,判断这一天是这一年的第几天?
思考:之前的月份天数的累加,先对年作出判断,再对月做判断
‘‘‘
year = input("请输入年") month = input("请输入月") day = input("请输入天") year = int(year) month = int(month) day = int(day) list1 = [31,28,31,30,31,30,31,31,30,31,30,31] total = day while month -1 >0: total += list1[month-2] month = month-1 # 能被400整除的,或者不能被100整除而能被4整除的年就是闰年 if year%400 == 0 or (year%4 == 0 and year%100 != 0): if month > 2: total += 1 print(total)
标签:day inpu 某月 判断 python练习 不能 class == pytho
原文地址:https://www.cnblogs.com/howiehuang/p/11121161.html