在Python中减去datetime和timedelta

时间:2014-01-22 05:36:30

标签: python django datetime

我将TimeField存储在Django中,我希望减去几分钟后再更新数据库。这就是我现在正在做的事情,结果是TpeError: unsupported operand type(s) for -: 'datetime.time' and 'datetime.timedelta'

>>> s.start_time
datetime.time(1, 0)
>>> from datetime import timedelta
>>> s.start_time - timedelta(minutes=30)
Traceback (most recent call last):
  File "<console>", line 1, in <module>
TypeError: unsupported operand type(s) for -: 'datetime.time' and 'datetime.timedelta'

怎么了?

0 个答案:

没有答案