1. 程式人生 > >Python time time()方法

Python time time()方法

oob 輸出 輸出結果 sha import print 語法 描述 ctime

from:http://www.runoob.com/python/att-time-time.html

描述

Python time time() 返回當前時間的時間戳(1970紀元後經過的浮點秒數)。

語法

time()方法語法:

time.time()

參數

  • NA。

返回值

返回當前時間的時間戳(1970紀元後經過的浮點秒數)。

實例

以下實例展示了 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

Python time time()方法