课堂练习

def date(x,y,z):
    list1 = [31,29,31,30,31,30,31,31,30,31,30,31]
    list2 = [31,28,31,30,31,30,31,31,30,31,30,31]
    z += 1
    if x % 4 == 0 or x % 100 == 0 or x % 400 == 0:
        if z > list1[y-1]:
            z = 1
            y += 1
            if y > 12:
                x += 1
                y = 1
                z = 1
    else:
        if z > list2[y-1]:
            z = 1
            y += 1
            if y > 12:
                x += 1
                y = 1
                z = 1
    return (x,y,z)

x=int(input('请输入年:'))
y=int(input('请输入月:'))
z=int(input('请输入日:'))
result = date(x,y,z)
print('输入日期的下一天是:%d年%d月%d日'% result)

  

猜你喜欢

转载自www.cnblogs.com/juzipishui/p/10207269.html