import datetime
from datetime import datetime, date, timedelta
def dayDateRange():
dates = []
for i in range(2, -1, -1):
yesterday = (date.today() + timedelta(days=-i)).strftime("%Y-%m-%d")  # 昨天日期
dates.append(yesterday)
return dates
if __name__ == '__main__':
print(dayDateRange())
pass
获取今天的日期:print(date.today().strftime("%Y-%m-%d"))