import time import datetime # 获取当前日期 time.localtime()[0:3] # 当前日期的前一天/后一天 daydelta=1 time.localtime(time.time()-86400*daydelta)[0:3] ################ # 直接使用datetime模块 yesterday=datetime.date(2014,02,03)+datetime.timedelta(days=-1) tomorrow=datetime.date(2014,02,03)+datetime.timedelta(minutes=+1) # timedelta=(weeks,days,hours,minutes,seconds)