软件测试经典问题——NextDate函数
给出今天日期(YYYY-MM-DD)
得出明天日期
c1. 1<=month<=12
c2. 1<=day<=31
c3. 0<year
print("输入今天的日期 yyyy mm dd!") todaydate=[0000,0,0] tomorrowdate=[0000,0,0] for i in range(3): todaydate[i]=int(input()) print ("今天的日期是:") print todaydate if((todaydate[2]<1)or(todaydate[2]>31)): print("日期错误!") elif((todaydate[1]<1)or(todaydate[1]>12)): print("月份错误") elif(todaydate[0]<1): print("年份错误") elif(todaydate[1]in[1,3,5,7,8,10]): if(todaydate[2]<31): tomorrowdate[2]=todaydate[2]+1 tomorrowdate[1]=todaydate[1] tomorrowdate[0]=todaydate[0] else: tomorrowdate[2]=1 tomorrowdate[1]=todaydate[1]+1 tomorrowdate[0]=todaydate[0] elif(todaydate[1]in[4,6,9,11]): if(todaydate[2]<30): tomorrowdate[2]=todaydate[2]+1 tomorrowdate[1]=todaydate[1] tomorrowdate[0]=todaydate[0] else: tomorrowdate[2]=1 tomorrowdate[1]=todaydate[1]+1 tomorrowdate[0]=todaydate[0] elif(todaydate[1]==12): if(todaydate[2]<31): tomorrowdate[2]=todaydate[2]+1 tomorrowdate[1]=todaydate[1] tomorrowdate[0]=todaydate[0] else: tomorrowdate[2]=1 tomorrowdate[1]=1 tomorrowdate[0]=todaydate[0]+1 elif(todaydate[1]==2): if(todaydate[2]<28): tomorrowdate[2]=todaydate[2]+1 tomorrowdate[1]=todaydate[1] tomorrowdate[0]=todaydate[0] elif(todaydate[2]==28): if((((todaydate[0]%400)==0)or(((todaydate[0]%10)!=0))and((todaydate[0]%4)==0))): tomorrowdate[2]=todaydate[2]+1 tomorrowdate[1]=2 tomorrowdate[0]=todaydate[0] elif(todaydate[2]==29): tomorrowdate[2]=1 tomorrowdate[1]=3 tomorrowdate[0]=todaydate[0] print ("明天的日期是 : ") print tomorrowdate