gpt4 book ai didi

datetime - os.difftime(t2, t1) 的用途是什么,但 t2 - t1 未涵盖?

转载 作者:行者123 更新时间:2023-12-03 09:24:18 25 4
gpt4 key购买 nike

在此代码中

t1 = os.time()
do_something_slow()
t2 = os.time()

elapsed_diff = os.difftime(t2, t1)
elapsed_sub = t2 - t1

什么情况下elapsed_diff会与elapsed_sub不同?

最佳答案

在非Posix系统中,不能保证os.time返回的值可以直接相减。

In the GNU C Library, you can simply subtract time_t values. But on other systems, the time_t data type might use some other encoding where subtraction doesn't work directly. [1]

关于datetime - os.difftime(t2, t1) 的用途是什么,但 t2 - t1 未涵盖?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24585840/

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