Python获取昨天日期
程序员文章站
2024-01-06 09:45:22
...
import datetime
def getYesterday():
today = datetime.date.today()
oneday = datetime.timedelta(days=1)
yesterday = today - oneday
return yesterday
print(getYesterday())
运行结果如下:
2020-12-24