我想为日期添加时间。日期和时间是字符串
12/28/2018 23:30:00
现在在这里我想添加时间
02:30:00
在输出中:
12/29/2018 02:30
我尝试了以下方法:
import datetime
from datetime import datetime, timedelta
departure_time = "15:30"
duration = "00:00:50"
#I convert the strings to datetime obj
departure_time_obj = datetime.strptime(departure_time_obj, '%H:%M')
duration_obj = datetime.strptime(duration_obj, '%H:%M:%S')
arrival_time = dtt + datetime.timedelta(duration_obj)
print(arrival_time)
我收到以下错误:
AttributeError: type object 'datetime.datetime' has no attribute 'timedelta'
隔江千里
相关分类