美文网首页
Python 实现获取【昨天】【今天】【明天】日期

Python 实现获取【昨天】【今天】【明天】日期

作者: 还是那个没头脑 | 来源:发表于2021-08-11 14:42 被阅读0次

昨天

from datetime import date, timedelta

yesterday = (date.today() + timedelta(days=-1)).strftime("%Y-%m-%d")
print(yesterday)

今天

from datetime import date, timedelta

today = date.today()
print(today)

明天

from datetime import date, timedelta

tomorrow = (date.today() + timedelta(days= 1)).strftime("%Y-%m-%d")
print(tomorrow)

相关文章

网友评论

      本文标题:Python 实现获取【昨天】【今天】【明天】日期

      本文链接:https://www.haomeiwen.com/subject/uflcbltx.html