当前日期时间
import datetime
print datetime.datetime.now()
# 2018-05-08 16:53:30.101000
格式化时间
import datetime
print datetime.datetime.now().strftime("%Y-%m-%d %H:%M")
# 2018-05-08 16:54
多加一天
import datetime
print (datetime.datetime.now()+datetime.timedelta(days=1)).strftime("%Y-%m-%d %H:%M:%S")
# 2018-05-09 16:56:07
减一天
import datetime
print (datetime.datetime.now()+datetime.timedelta(days=-1)).strftime("%Y-%m-%d %H:%M:%S")
# 2018-05-07 16:56:59
其他类似
import datetime
in_date = '2016-08-31'
dt = datetime.datetime.strptime(in_date, "%Y-%m-%d")
out_date = (dt + datetime.timedelta(days=2)).strftime("%Y-%m-%d")
print(out_date)
# 2016-09-02
可