# 如果是 0 则为今天
def getdate(day): today = datetime.datetime.now() deviation = datetime.timedelta(days=-day) return (today + deviation).strftime('%Y-%m-%d %H:%S:%M') print(getdate(0))