python - datetime日期加减
import datetime
now = datetime.datetime.now()
# now = datetime.datetime(2023,4,9)
now.strftime('%Y-%m-%d %H:%M:%S')
# 2023-04-09 21:00:41
# 加7天
delta7 = datetime.timedelta(days=7)
(now+delta7).strftime('%Y-%m-%d %H:%M:%S')
# 2023-04-16 21:00:41
# 减7天
delta7 = datetime.timedelta(days=7)
(now-delta7).strftime('%Y-%m-%d %H:%M:%S')
# 2023-04-02 21:00:41