获取昨天的时间

方法一:
>>> from datetime import date, timedelta
>>> (date.today() - timedelta(1))
datetime.date(2008, 12, 11)
>>>
>>> (date.today() - timedelta(20)).isoformat()
'2008-11-22'
>>>

方法二:
>>> import time
>>> now  = time.time()
>>> yesterdayTuple = time.localtime(now-60*60*24)

>>> yesterdayTuple
(2008, 12, 11, 10, 13, 24, 3, 346, 0)

你可能感兴趣的:(tips)