Oct-28-2020, 09:59 PM
Hi, I'm trying to convert "time" string and a code I wrote works fine until I add a print statement.
It produces error " print(datetime.timedelta(td_sec))
AttributeError: type object 'datetime.datetime' has no attribute 'timedelta'"
Code:
It produces error " print(datetime.timedelta(td_sec))
AttributeError: type object 'datetime.datetime' has no attribute 'timedelta'"
Code:
from datetime import datetime
# Some code here #
if tstamp1 > tstamp2:
td = tstamp1 - tstamp2
tdif = str(td)
print ("TIME Difference -------------------------------",tdif)
td_sec = int(round(td.total_seconds()))
td_sec=int(td_sec)
print('The difference IN SEONDS ---------%s seconds' % td_sec)Print statement That produses the error:print(datetime.timedelta(td_sec))Thank you! Any help will be appreciated!
