from time import strftime, localtime
from datetime import timedelta, date
import calendar
import datetime
print strftime("%Y-%m-%d %H:%M:%S",localtime())
print date.today()-timedelta(-1)
threeDayAgo = (datetime.datetime.now() - datetime.timedelta(days = 3))
print threeDayAgo.strftime("%Y-%m-%d %H:%M:%S")
~
结果如下:
2016-03-30 17:46:48
2016-03-31
2016-03-27 17:46:48