相当于python time.time()-在golang中启动
在python中,我可以看到在一个特定的过程中经过了多少秒相当于python time.time()-在golang中启动,go,Go,在python中,我可以看到在一个特定的过程中经过了多少秒 started = time.time() doProcess() print(time.time()-started) golang的等价物是什么 import ( "fmt" "time" ) func main() { started := time.Now() doProcess() fmt.Println(time.Now().Sub(started).Seconds()) }
started = time.time()
doProcess()
print(time.time()-started)
golang的等价物是什么
import (
"fmt"
"time"
)
func main() {
started := time.Now()
doProcess()
fmt.Println(time.Now().Sub(started).Seconds())
}
自返回自t以来经过的时间。这是英语的简写
time.Now()Sub(t)
Go中的Python示例:
package main
import (
"fmt"
"time"
)
func main() {
started := time.Now()
time.Sleep(1 * time.Second)
fmt.Println(time.Since(started))
}
输出:
1s
自返回自t以来经过的时间。这是英语的简写
time.Now()Sub(t)
Go中的Python示例:
package main
import (
"fmt"
"time"
)
func main() {
started := time.Now()
time.Sleep(1 * time.Second)
fmt.Println(time.Since(started))
}
输出:
1s