0%

python昨天

python获取昨天日期

1
2
3
4
5
>>> import datetime
>>> datetime.date.today() + datetime.timedelta(-1)
datetime.date(2021, 5, 10)
>>> (datetime.date.today() + datetime.timedelta(-1)).strftime("%Y%m%d")
'20210510'