gpt4 book ai didi

python - 从今天到给定日期还有多少天

转载 作者:太空狗 更新时间:2023-10-29 22:03:07 25 4
gpt4 key购买 nike

我有一个约会 - 2015.05.20

使用 python 计算从今天到这个日期还剩多少天的最佳方法是什么?

from datetime import *
today = date.today()
future = date(2015,05,20)
???

最佳答案

import datetime

today = datetime.date.today()
future = datetime.date(2019,9,20)
diff = future - today
print (diff.days)

difftimedelta对象。

关于python - 从今天到给定日期还有多少天,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7628036/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com