【发布时间】:2015-10-08 16:52:28
【问题描述】:
我需要以小时为单位添加两个时间增量。目前我这样做:
t_day = timedelta(hours=self.time_day_hours,
minutes=self.time_day_minutes)
t_night = timedelta(hours=self.time_night_hours,
minutes=self.time_night_minutes)
total = str(t_day + t_night)[:-3]
仅当总时间少于 1 天时才有效。如果它更高,它将开始新的一天。我不想要这个。例如,我想要:
7h56m + 21h05m = 29h01m
如何将时间增量相加并获得总小时数?
【问题讨论】:
-
你是什么意思“两个小时”?时间?
-
是的,你说得对,对不起,我的意思是两次(这在法语中是这样说的)。
标签: python python-3.x time