python获取指定日期的前N天日期和后N天日期

#encoding:utf-8
from datetime import date, datetime, timedelta

day = date.today()
now = datetime.now()
delta = timedelta(days=5)
n_days_after = now + delta
n_days_forward = now - delta
print(("当前日期:{}").format(day))
print("向后推迟5天的日期:{}".format(n_days_after.strftime('%Y-%m-%d')))
print("向前推5天的日期:{}".format(n_days_forward.strftime('%Y-%m-%d')))

上一篇:WDA基础十六:ALV的颜色


下一篇:再起航,我的学习笔记之JavaScript设计模式27(链模式)