目录

time.time( )

描述 (Description)

方法time()将时间作为以UTC为单位以秒为单位表示的浮点数返回。

Note - 即使始终将时间作为浮点数返回,并非所有系统都提供精度高于1秒的时间。 虽然此函数通常返回非递减值,但如果在两次调用之间设置了系统时钟,则它可以返回比先前调用更低的值。

语法 (Syntax)

以下是time()方法的语法 -

time.time()

参数 (Parameters)

  • NA

返回值 (Return Value)

此方法将时间作为以UTC为单位以秒为单位表示的浮点数返回。

例子 (Example)

以下示例显示了time()方法的用法。

#!/usr/bin/python
import time
print "time.time(): %f " %  time.time()
print time.localtime( time.time() )
print time.asctime( time.localtime(time.time()) )

当我们运行上面的程序时,它产生以下结果 -

time.time(): 1234892919.655932
(2009, 2, 17, 10, 48, 39, 1, 48, 0)
Tue Feb 17 10:48:39 2009
↑回到顶部↑
WIKI教程 @2018