【发布时间】:2015-09-18 20:51:48
【问题描述】:
我想在 python 中做类似2h35 + 0h56 的事情。所以这就是我尝试过的:
>>> t1 = time(2, 35)
>>> t2 = time(0, 56)
>>> t3 = t1 + t2
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: unsupported operand type(s) for +: 'datetime.time' and 'datetime.time'
如何在 Python 中一次添加时间? Stackoverflow 上的所有主题都要求在日期上添加时间,但我只需要时间而不是日期!
感谢您的帮助
【问题讨论】:
-
time(14, 0) + time(14, 0)应该产生什么(或任何其他时间加起来超过一天? -
简单,
28h!可以超过一天。
标签: python-3.x