一个datetime类型的日期 cur_dt = '2021-03-01'
想要得到前一天、后一天的日期:
import datetime
previous_date = cur_dt - datetime.timedelta(1)
# output: Timestamp('2021-02-28 00:00:00')
next_date = cur_dt + datetime.timedelta(1)
# output: Timestamp('2021-03-02 00:00:00')
一个datetime类型的日期 cur_dt = '2021-03-01'
想要得到前一天、后一天的日期:
import datetime
previous_date = cur_dt - datetime.timedelta(1)
# output: Timestamp('2021-02-28 00:00:00')
next_date = cur_dt + datetime.timedelta(1)
# output: Timestamp('2021-03-02 00:00:00')