0

我有一堆现场数据,其中一些有一个众所周知的采集日,而对于一些采集只是已知的不确定性,例如 +/- 1.5 个月。

是否有诸如“不确定的日期时间对象”之类的东西可以处理这些不确定性?

我正在考虑只为日和月插入“99”和“99”作为零阶方法,然后例如创建一个将日期标记为不确定的 Enum 对象。但首先插入 9 不起作用,因为 datetime 非常注意在实例化 datetime 对象时插入有效的月份和日期。有没有更聪明的方法?是否有一个已经存在的包可以处理不确定的日期?

4

1 回答 1

0

An entry like +/- 1.5 is a difference from some measured time. One way you can codify this is with a timedelta object, which represents the difference in two datetime objects.

Here is how you would represent an interval of minus five minutes:

import datetime

i = datetime.timedelta(minutes=-5)

Now, to calculate a time you just add that to an actual date time value.

于 2018-07-19T06:35:43.997 回答