为什么(BDate)显示为语法错误

时间:2019-06-12 05:56:06

标签: python

enter image description here enter image description here 我已尽力尝试一切都行不通

print ("Enter today's date:")
DateToday = input()
print ("Enter your birthday {yyyy/mm/d)"
BDate = input()
Age = DateToday - BDate
print Age.year 

1 个答案:

答案 0 :(得分:0)

我假设您只想要一年的年龄? 在这种情况下,您可以这样做:

datetoday = int(input("Enter the current year: "))
bdate = int(input("Enter your birth year: "))
age = datetoday - bdate
print ("Your age is: " + str(age))

您忘记添加一些括号,并索要不必要的数据。这将给一个人几岁。