您的位置:首页 >我爱生活 >

time clock battery ng(time clock)

导读 大家好,我是小青,我来为大家解答以上问题。time clock battery ng,time clock很多人还不知道,现在让我们一起来看看吧!一,两个函...

大家好,我是小青,我来为大家解答以上问题。time clock battery ng,time clock很多人还不知道,现在让我们一起来看看吧!

一,两个函数的文档:

1,time.time():

time.time()

Return

the time in seconds since the epoch as a floating point number. Note

that even though the time is always returned as a floating point number,

not all systems provide time with a better precision than 1 second.

While this function normally returns non-decreasing values, it can

return a lower value than a previous call if the system clock has been

set back between the two calls.

time.time()

返回从纪元(1970.1.1)至今的秒数。虽然这个函数的返回值永远为浮点数,但并不是所有系统提供的秒数都会精确到小数点以后。一般情况下这个函数的返回值不会小于它上一次被调用的返回值,除非系统时钟在两次调用之间发生了重置。

2,time.clock():

time.clock()

On

Unix, return the current processor time as a floating point number

expressed in seconds. The precision, and in fact the very definition of

the meaning of “processor time”, depends on that of the C function of

the same name, but in any case, this is the function to use for

benchmarking Python or timing algorithms.

On Windows, this

function returns wall-clock seconds elapsed since the first call to this

function, as a floating point number, based on the Win32 function QueryPerformanceCounter(). The resolution is typically better than one microsecond.

time.clock()

在Unix 中,将当前的处理器时间以浮点数的形式返回,单位为秒。它的精确度(准确地说是“处理器时间”的精确度)取决于同名的C函数,无论如何,这个函数是python关于时间计算的标尺。

WINDOWS中,第一次调用,返回的是进程运行的实际时间。而第二次之后的调用是自第一次调用以后到现在的运行时间。(实际上是以WIN32上QueryPerformanceCounter()为基础,它比毫秒表示更为精确)

二,用法及总结

1,在Windows中,time.clock()更精确;

2,这两个函数不可以混合使用;

本文到此讲解完毕了,希望对大家有帮助。

免责声明:本文由用户上传,如有侵权请联系删除!