是想删除前面的days, 数还需要添加到后面的时分秒吗?
试下这个:
import time
import datetime
t=input()
t=time.strptime(t,'%H:%M:%S')
H,M,S=t[3:6]
seconds=eval(input())
seconds=seconds%(24*3600)
hour=seconds//3600
seconds%=3600
minutes=seconds//60
seconds%=60
t1=datetime.timedelta(hours=H+hour,minutes=M+minutes,seconds=seconds+S)
print(t1)
from datetime import timedelta
def format_timedelta(td):
minutes, seconds = divmod(td.seconds + td.days * 86400, 60)
hours, minutes = divmod(minutes, 60)
return '{:d}:{:02d}:{:02d}'.format(hours, minutes, seconds)
str_t1 = str(t1)
format_timedelta(timedelta(days=int(str_t1.split(' ')[0]),
hours=int(str_t1.split(' ')[2].split(':')[0]),
minutes=int(str_t1.split(':')[1]),
seconds=int(str_t1.split(':')[2])))