问题
This is copied straight out of my console:
>>> import isodate
>>> import datetime
First statements are as expected. 1 month duration not longer than 10 years duration.
>>> duration = isodate.parse_duration("P1M")
>>> duration > isodate.duration.Duration(0, 0, 0, years=10, months=0)
False
But then I get 1 month duration is longer than 10 years duration all of a sudden.
>>> duration = isodate.parse_duration("P1M")
>>> isinstance(duration, isodate.Duration)
True
>>> duration > isodate.duration.Duration(0, 0, 0, years=10, months=0)
True
>>> duration
isodate.duration.Duration(0, 0, 0, years=0, months=1)
What is happening here that I don't understand.
来源:https://stackoverflow.com/questions/52332509/isodate-duration-duration-duration-comparison-is-inconsistent