gpt4 book ai didi

python - 计算 OOZIE 时间戳差异的最佳方法是什么?

转载 作者:行者123 更新时间:2023-12-04 09:23:34 25 4
gpt4 key购买 nike

我有 2 个以这种格式从 OOZIE 派生的时间戳:
2019-07-20T16:34:45.000Z

2020-08-20T16:20:15.000Z
我如何找到 时差以秒/分钟/天为单位?哪个python库可以提供帮助?有什么建议?

最佳答案

我不知道任何图书馆,但你可以自己做。
我正在分享一个可能有效的代码。

time_stamp1 = input("Time stamp1")
time_stamp2 = input("Time stamp2")
yrs = int(time_stamp1[:4]) - int(time_stamp2[:4])
mnths = int(time_stamp1[5:7]) - int(time_stamp2[5:7])
days = int(time_stamp1[8:10]) - int(time_stamp1[8:10])
hrs = int(time_stamp1[11:13]) - int(time_stamp2[11:13])
min = int(time_stamp1[14:16]) - int(time_stamp1[14:16])
sec = int(time_stamp1[17:19]) - int(time_stamp1[17:19])
ms = int(time_stamp1[20:23]) - int(time_stamp1[20:23])
print(yrs, mnths, days)
print(hrs, min, sec, ms)
如果您不想知道时间戳 2 是否早于时间戳 1,则可以使用 abs() 函数,反之亦然。

关于python - 计算 OOZIE 时间戳差异的最佳方法是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63060454/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com