Python time.time() 方法及代码示例

返回从epoch到现在的时间,epoch表示时间开始的点

在 Windows 和大多数 Unix 系统中, epoch 是 1970 年 1 月 1 日 00:00:00 (UTC)

定义

time.time()

返回值

返回从epoch到现在的时间

注意事项

注意,即使返回时间是浮点数,但并非所有系统都提供高于1秒的精度

示例

import time

t = time.time()
print(t)

执行结果为 :

1632969304.1701205