def part_1(began_year, began_month, began_day, end_year, end_month, end_day):
import calendar
days_in_month = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 31, 30, 31]
if began_year % 400 == 0 or began_year % 4 == 0 and began_year % 100 != 0:
leap_year = True
else:
leap_year = False
if end_year % 400 == 0 or end_year % 4 == 0 and end_year % 100 != 0:
leap_year = True
else:
leap_year = False
if began_month < 1 or began_month > 12:
print("输入错误")
return
if began_day > days_in_month[began_month] or began_day < 1:
print("输入错误")
return
if end_month < 1 or end_month > 12:
print("输入错误")
return
if end_day > days_in_month[end_month] or end_day < 1:
print("输入错误")
return
total_days = 0
if began_year == end_year:
total_days = calendar.monthrange(end_year, end_month)[1] - calendar.monthrange(began_year, began_month)[1] + 1
elif began_year + 1 == end_year:
if leap_year:
total_days = 366 + calendar.monthrange(end_year, end_month)[1] - calendar.monthrange(began_year, began_day)[1]
else:
total_days = 365 + calendar.monthrange(end_year, end_month)[1] - calendar.monthrange(began_year, began_day)[1]
else:
for _ in range(began_year + 1, end_year):
if leap_year:
n = 366
else:
n = 365
total_days += n
if _ % 400 == 0 or _ % 4 == 0 and _ % 100 != 0:
leap_year = True
if leap_year:
total_days += calendar.monthrange(end_year, end_month)[1] - calendar.monthrange(began_year, began_day)[1]
else:
total_days += calendar.monthrange(end_year, end_month)[1] - calendar.monthrange(began_year, began_day)[1]
print("合计天数:", total_days)
if __name__ == "__main__":
began_year, began_month, began_day = list(map(int, input().split()))
end_year, end_month, end_day = list(map(int, input().split()))
part_1(began_year,began_month,began_day,end_year,end_month,end_day)
没有合适的资源?快使用搜索试试~ 我知道了~
测试源代码.zip
共156个文件
txt:156个
需积分: 0 0 下载量 184 浏览量
2023-12-28
21:45:31
上传
评论
收藏 42KB ZIP 举报
温馨提示
测试源代码.zip
资源推荐
资源详情
资源评论
收起资源包目录
测试源代码.zip (156个子文件)
202212007423李子才.txt 2KB
202212005593刘道阳.txt 926B
202212007397 王凯振.txt 895B
202212005155邵冠程.txt 893B
202212007398周仲乐.txt 890B
202212005365王祥宇.txt 885B
202212007714黄煜程.txt 753B
202212007292代依凡.txt 664B
202212007313齐富.txt 626B
202212007374安子阳.txt 621B
200012007325温冲冲.txt 588B
202212007709吕金滢.txt 587B
202212007738石家硕.txt 572B
202212007719刘世功.txt 554B
202212007727赵洋.txt 550B
202212007415陈梦佳 (2).txt 483B
202212007360王翔.txt 452B
202212007361王鑫华.txt 452B
202212005168季学江.txt 431B
202212007365张明智.txt 412B
202212007347任雪雨.txt 410B
202212007349刘延鹏.txt 408B
202212007375刘佳.txt 406B
202212007269石志远.txt 401B
202212007303张广旭.txt 400B
202212005331 朱俊宇.txt 392B
202212007267潘亚宁.txt 391B
202212007328 贾舒.txt 390B
202212007344 李树博.txt 390B
202212007250 薛晓羽.txt 388B
202212007245牟军政.txt 387B
202212007285李佳昕.txt 380B
202212007708揣涵竣.txt 372B
202212007763马炳钦 .txt 340B
202212007378王庆煜.txt 340B
202212007749薛领民.txt 336B
202212007354李宁.txt 336B
202212007421耿慧茹.txt 335B
202212005363陈雯.txt 334B
202212007317彭泺鑫.txt 334B
202212007299李家绪.txt 333B
202212007309李峰宇.txt 333B
202212005277郭逸嘉.txt 330B
202212005165孙文卿.txt 328B
202212005152刘昱慧.txt 328B
202212005150任星恺.txt 328B
202212005275李涵.txt 326B
202212005503刘泽旭.txt 326B
202212007754刘兆理.txt 326B
202212007734_霍本建.txt 324B
202212005411赵志豪.txt 319B
202212007383-徐春芳.txt 315B
202212007380-于群章.txt 311B
202212005555张志伟.txt 311B
202212005362王清义.txt 300B
202212007412程文慧.txt 297B
202212007688闫博雯.txt 289B
202212007418宋志圆.txt 284B
202212007716郭明毅.txt 284B
202212007735张毓卓.txt 282B
202212007706张俊镐.txt 282B
202212007717刘晔豪.txt 266B
202212007715王东辉.txt 259B
202212005280赵莹慧.txt 259B
202212005538贺庆宏.txt 258B
202212007286孙子豪.txt 254B
202212005162李莹莹.txt 250B
202212007705王正丰.txt 248B
202212007326汪园园.txt 247B
202212007316刘玉坤.txt 246B
202212007739田鑫.txt 244B
202212007707曹鸣洋.txt 243B
202212007291刘晓丽.txt 243B
202212007424朱尧廷.txt 232B
202212007363尚磊.txt 231B
202212007422单世涛.txt 230B
202212007377杨智晗.txt 229B
202212005149陈开阔.txt 229B
202212007329裴庆宇.txt 229B
202212005406满继邦.txt 227B
202212005297冯春阳.txt 227B
202212007376陈梦.txt 227B
202212007409赵昱杉.txt 226B
202212005278孙红雨.txt 226B
202212007746惠怡硕.txt 225B
202212007406徐宇杰.txt 216B
202212007417陈永行.txt 209B
202212007400陈兆兴.txt 209B
202212007730吴家豪.txt 204B
202212007718吕博言.txt 202B
202212007410苏慧.txt 199B
202212007687田安琪.txt 199B
202212007710徐永鹏.txt 193B
202212007713郭冰怡.txt 193B
202212005147刘长鑫.txt 180B
202212007358王玺.txt 178B
202212007419牟冰.txt 177B
202212007306杜浩杰.txt 174B
202212007414_张娟.txt 172B
202212007289鞠礼安.txt 170B
共 156 条
- 1
- 2
资源评论
2301_78237026
- 粉丝: 0
- 资源: 1
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功