Latest web development tutorials

Pythonの時間時間()メソッド

説明

Pythonの時間時間は、()(秒の浮動小数点数の後エポック1970)、現在の時刻のタイムスタンプを返します。

文法

時間()メソッドの構文:

time.time()

パラメータ

  • NA。

戻り値

(秒の浮動小数点数の後エポック1970)、現在の時刻のタイムスタンプを返します。

次の例では、使用する時間()関数を示しています。

#!/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