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

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

到目前为止,我得到的是: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. "))

age = gYear - bYear

if bMonth > gMonth:

age = age - 1

aMonth =

if bMonth == gMonth and bDay > gDay:

age = age - 1

print(name, 'you will be', age, 'years old by the time you graduate. Thanks for the information.')

我刚刚开始使用Python,但它看起来很简单。例如,我想提示用户他们的出生年份、出生月份和出生日期。然后我要提示用户他们毕业的年份、毕业的月份和毕业的日期。然后我希望程序计算这些日期之间的差异,并输出以年、月、日为单位的人的年龄。在

例如

^{pr2}$

你可能感兴趣的:(python输入年月日输出年月日_如何提示用户输入两个日期并输出年月日的日期差?...)