from datetime import datetime, time, timedelta
att1 = datetime.strptime('09:00 AM','%H:%M %p')
att2 = datetime.timedelta(minutes = 15)
time_zero = datetime.strptime('00:00 AM','%H:%M %p')
att3 = (att1 - time_zero + att2).strftime("%X %p")
print(" sTime and Approx time is",att3)
如果我从att2删除了datetime,它将影响到att3 att3 =(att1-time_zero + att2).strftime(“%X%p”) AttributeError:“ datetime.timedelta”对象没有属性“ strftime”
错误
回溯(最近通话最近一次):
中的文件“ addtwotimes.py”,第5行
att2 = datetime.datetime(minutes = 15)
AttributeError:类型对象'datetime.datetime'没有属性 'timedelta'