from datetime import datetime, timedelta
</code><code>dt = datetime.now()
print dt
<span style="color: #008000;">#输出为:2017-09-04 13:26:29.954000</span>
前一天:<code>yesterday = dt-timedelta(days=1)
<span style="color: #008000;">#输出为:2017-09-03 13:26:29.954000</span>
后一天:<code>tomorrow = dt+timedelta(days=1)
<span style="color: #008000;">#输出为:2017-09-05 13:26:29.954000</span>
指定日期 如2017-04-04
dt = datetime(2017,4,4)
<span style="color: #008000;">#输出为:2017-04-03 00:00:00</span>
网友评论