gpt4 book ai didi

go - 相当于 python time.time()-在 golang 中启动

转载 作者:IT王子 更新时间:2023-10-29 02:29:19 24 4
gpt4 key购买 nike

在 python 中,我可以看到在特定过程中经过了多少秒,例如,

started = time.time()
doProcess()
print(time.time()-started)

golang 中的等价物是什么?

最佳答案

import (
"fmt"
"time"
)

func main() {
begin := time.Now()
time.Sleep(10 * time.Millisecond)
end := time.Now()

duration := end.Sub(begin)

fmt.Println(duration)

}

关于go - 相当于 python time.time()-在 golang 中启动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43953459/

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