days = function1(year, month, day)
if month in [1, 3, 5, 7, 8, 10, 12]: # 月份在 [1, 3, 5, 7, 8, 10...elif month in [4, 6, 8, 10]: # 月份在 [4, 6, 8, 10]
assert (1 的天数范围 断言正确...可以计算
days = function1(year, month, day)
break
elif month == 2: # 2月份 闰年29天 非闰年 28天
if..., month, day)
break
except ValueError: # 转int包含非法字符 ValueError
print('日期中不能包含非法字符')
except...(days))
测试结果如下:
请输入日期:2020/8/29
该日期是这一年的第242天
Process finished with exit code 0
2.