python输入年月日输出年月日_如何提示用户输入两个日期并输出年月日的日期差?...

这篇博客探讨了如何使用Python提示用户输入出生日期和预计毕业日期,并计算两者之间的日期差。作者分享了初步的代码实现,该代码计算年份差,并处理了月份和天数的调整。博客内容适合Python初学者,旨在教授日期处理的基础知识。
摘要由CSDN通过智能技术生成

我一直在寻找一个明确的答案。我读过很多关于使用日期时间的帖子和其他网站,但是我如何构建一个简单的程序来提示用户输入两个特定的日期,然后计算这些日期之间的差异呢?我一直在琢磨如何得到月份和天数。在

到目前为止,我得到的是:print ("How old will you be when you graduate?")

print ("If you want to know, I'll have to ask you a few questions.")

name = input('What is your name? ')

bYear = int(input("What year were you born? "))

print ("Don't worry. Your information is safe with me.")

bMonth = int(input("What month were you born? "))

bDay = int(input("How about the day you were born? "))

print ("Fantastic. We're almost done here.")

gYear = int(input("What year do you think you'll graduate? "))

gMonth = int(input("What about the month? "))

gDay = int(input("While you're at it, give me the day too. "))

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值