首页 > 文章列表 > python time库有哪些时钟

python time库有哪些时钟

Python time
432 2022-08-07

时钟说明

1、monotonic测量长时间运行过程需要时间。

因为即使系统时间发生变化,也能保证钟不会逆转。

2、perf_counter允许访问最高可用分辨率的时钟。

使短时间测量更加正确。

3、process_time返回处理器时间和系统时间的组合结果。

4、time回到纪元以来的秒数。

UNIX系统从1970年1月1日00:00开始计算。

实例

import time
 
print(time.monotonic())
print(time.monotonic_ns())
print(time.perf_counter())
print(time.perf_counter_ns())
print(time.process_time())
print(time.process_time_ns())
print(time.time())
print(time.time_ns())

本文教程操作环境:windows7系统、Python 3.9.1,DELL G3电脑。