Python计算两个日期之间的相差的秒数

清华大佬耗费三个月吐血整理的几百G的资源,免费分享!....>>>

python时间差计算,以秒统计

>>> import datetime,time
>>> def dateDiffInSeconds(date1, date2):
...     timedelta = date2 - date1
...     return timedelta.days*24*3600 + timedelta.seconds
...
>>> date1 = datetime.datetime(2006,02,17,15,30,00)
>>> date2 = datetime.datetime(2006,05,18,11,01,00)
>>> print dateDiffInSeconds(date1,date2)
7759860
>>>