time_1 = datetime.timedelta(hours = hours_1, minutes = minutes_1, seconds = seconds_1)
time_2 = datetime.timedelta(hours = hours_2, minutes = minutes_2, seconds = seconds_2)
添加时会在days
和hours
中给出答案,但我真的只想要总小时数。
答案 0 :(得分:0)
这应该有所帮助。
import datetime
time_1 = datetime.timedelta(hours = 10, minutes = 2, seconds = 5)
time_2 = datetime.timedelta(hours = 30, minutes = 5, seconds = 7)
print(time_1 + time_2)
print(((time_1 + time_2).total_seconds()/60)/60)
<强>输出:强>
1 day, 16:07:12
40.12