0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

pythonでプログラムを開始した時点からの時刻を出力する

Posted at

pythonでプログラムを開始した時点からの時刻を出力するだけです。

test.py
#-*- using:utf-8 -*-
import time

if __name__ == '__main__':
    start_time = time.time()

    while True:
        time.sleep(1);
        elapsed_time = time.time() - start_time
        print ("elapsed_time:{0}".format(elapsed_time) + "[sec]")

実行結果

$ python3 test.py
elapsed_time:1.0001800060272217[sec]
elapsed_time:2.0004279613494873[sec]
elapsed_time:3.0007290840148926[sec]
elapsed_time:4.001792907714844[sec]
elapsed_time:5.0019917488098145[sec]

参考

time --- 時刻データへのアクセスと変換

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?