如何用relativdelta获得罗纳尔多和梅西的总上场时间?

例如。

ronaldo = relativedelta(years=0, months=0, days=0, hours=0, minutes=92)
messi = relativedelta(years=0, months=0, days=0, hours=0, minutes=91)


总计= 3小时05分钟

最佳答案

您可以将它们简单地添加在一起:

>>> from dateutil.relativedelta import *
>>>
>>> r1 = relativedelta(minutes=91)
>>> r2 = relativedelta(minutes=92)
>>> r1 + r2
relativedelta(hours=+3, minutes=+3)

10-07 17:51