Le 17/12/11 11:19, nukeymusic a écrit :
That's work:I'm trying to calculate the difference in seconds between two timestamps, but I'm totally stuck: date1="Dec-13-09:47:12" date2="Dec-13-09:47:39"diff=datetime.date(date2)-datetime.date(date1)Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: an integer is requiredstruct_date1=time.strptime(date1, "%b-%d-%H:%M:%S") struct_date2=time.strptime(date2, "%b-%d-%H:%M:%S")diff=datetime.date(struct_date2)-datetime.date(struct_date1)Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: an integer is required thanks in advance nukey import datetime begin = datetime.datetime(2011, 12, 13, 9, 47, 12) today = datetime.datetime(2011, 12, 13, 9, 47, 39) dif = str(today - begin) print dif >>> 0:00:27 Regards |
-- http://mail.python.org/mailman/listinfo/python-list