描述
Pythom時間法time()以自紀元以來的秒數表示的浮點數返回時間,以 UTC 為單位。
注意- 盡管時間總是作為浮點數返回,但並非所有係統都提供比 1 秒更好的時間精度。雖然此函數通常返回非遞減值,但如果係統時鍾在兩次調用之間已回退,則它可以返回比前一次調用低的值。
用法
以下是語法time()方法≫
time.time()
參數
NA
返回值
此方法以浮點數形式返回時間,以自紀元以來的秒數表示,以 UTC 為單位。
示例
下麵的例子展示了 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 tzset()用法及代碼示例
- Python time ctime()用法及代碼示例
- Python time mktime()用法及代碼示例
- Python time localtime()用法及代碼示例
- Python time sleep()用法及代碼示例
- Python time strftime()用法及代碼示例
- Python time clock()用法及代碼示例
- Python time asctime()用法及代碼示例
- Python time altzone()用法及代碼示例
- Python time replace()用法及代碼示例
- Python time gmtime()用法及代碼示例
- Python time strptime()用法及代碼示例
- Python time.monotonic()用法及代碼示例
- Python time.asctime()用法及代碼示例
- Python time.ctime()用法及代碼示例
- Python time.perf_counter()用法及代碼示例
- Python time.get_clock_info()用法及代碼示例
- Python time.gmtime()用法及代碼示例
- Python time.time()用法及代碼示例
- Python time.mktime()用法及代碼示例
注:本文由純淨天空篩選整理自 Python time time() Method。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。