datetime相减
>>> datetime.datetime.now()
datetime.datetime(2012, 3, 19, 8, 40, 39, 966543)
>>> datetime.datetime.now()
datetime.datetime(2012, 3, 19, 8, 40, 44, 441431)
>>> a=datetime.datetime.now()
>>> a
datetime.datetime(2012, 3, 19, 8, 40, 50, 737418)
>>> b=datetime.datetime.now()
>>> b
datetime.datetime(2012, 3, 19, 8, 41, 3, 849623)
>>> b-a
datetime.timedelta(0, 13, 112205)
>>> (b-a).seconds
13
>>> (b-a).days
0
>>> (b-a).hours
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'datetime.timedelta' object has no attribute 'hours'
>>> (b-a).hour
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'datetime.timedelta' object has no attribute 'hour'
>>> (b-a).minutes
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'datetime.timedelta' object has no attribute 'minutes'
>>> (b-a).microseconds 微妙
112205
>>> 849623-737418
112205
>>>