Python 如何获取前天的日期

获取今天前几天的日期

import datetime
def getDay(day):
  today = datetime.date.today()
  oneday = datetime.timedelta(days=day)
  return today - oneday
print(getDay(1))

你可能感兴趣的:(Python 如何获取前天的日期)