【发布时间】:2021-01-11 02:26:18
【问题描述】:
我正在做一个小项目,代码将大致计算出它们 10 亿秒时的日期。我已经完成了,但我有一个问题。如果用户输入“5”作为月份或更高,则月份将超过 12。对于日期,如果用户输入“24”或更高,它将超过 31 天。我如何使它不会超过“12”几个月和“31”几天。唯一的问题是月份和日期,年份工作正常。谢谢!
运行代码时,您可以使用的示例是,“10”代表月份,“24”代表日,“2020”代表年。
代码:
month = int(input("What Month Were You Born In: "))
day = int(input("What Day Was It: "))
year = int(input("What Year Was It: "))
sum1 = day + 7
sum2 = month + 8
sum3 = year + 32
print("You will be a billion seconds old approximately around, " + str(sum1) + "/" + str(sum2) + "/" + str(sum3))
【问题讨论】:
-
这能回答你的问题吗? Convert timedelta to total seconds
标签: python