Python 实现获取【昨天】【今天】【明天】日期
2021-08-11 本文已影响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)