import datetime
dateStr = '2018-09-01'
today = datetime.datetime.strptime(dateStr, '%Y-%m-%d')
yesterday = today - datetime.timedelta(1)#前一天日期
tomorrow = today + datetime.timedelta(1)#后一天日期
print(yesterday.strftime('%Y-%m-%d'))
#2018-08-31
print(tomorrow.strftime('%Y-%m-%d'))

 

posted on 2018-10-10 21:48  math98  阅读(276)  评论(0)    收藏  举报