使用出生日期和当前日期计算年龄。python 3.6.2

2024-04-29 00:40:56 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在为一个介绍python类做作业,不知道如何使用我的出生日期和当前日期计算年龄。在

print("Hello, welcome to Hopper's Computer Museum! To determine your entrance fee, please enter the following:")
dob = int(input("Your Date of Birth (mm dd yyyy)-: "))
currentdate = int(input("Today's date (mm dd yyyy): "))

任何帮助从哪里开始从我已经有代码将是美妙的。我不知道如何使用输入mm-dd-yyyy来计算年龄。在


Tags: tohelloinputddcomputer出生日期intmm
1条回答
网友
1楼 · 发布于 2024-04-29 00:40:56

为什么不简单地用当前日期减去出生年份呢?你会知道你活了多少年。如果你想准确地知道它,那么减去月份和日期。在

相关问题 更多 >