在datetime模块中有一个timedelta这个方法,它代表两个datetime之间的时间差。、
In [42]: datetime.datetime.now().strftime('%Y-%m-%d %H:%M')
Out[42]: '2017-06-23 17:27'
In [36]: (datetime.datetime.now() + datetime.timedelta(days=-1)).strftime('%Y-%m-%d %H:%M')
Out[36]: '2017-06-22 17:27'
In [37]: (datetime.datetime.now() + datetime.timedelta(days=1)).strftime('%Y-%m-%d %H:%M')
Out[37]: '2017-06-24 17:27'
In [41]: (datetime.datetime.now() + datetime.timedelta(minutes=5)).strftime('%Y-%m-%d %H:%M')
Out[41]: '2017-06-23 17:32'