0
0

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.

データロギング用に経過時間を出力(自分用)

Last updated at Posted at 2020-04-28

ストップウオッチ

自分用のメモです。

温度などのデータのロギング用のストップウオッチ的なものです。
通常は時刻を記録するのですが、今回は経過時間を記録するために作成したテストプログラムです。

python
import datetime
import time


def main():
    s_time = datetime.datetime.now()
    while True:
        time.sleep(2)
        now_time = datetime.datetime.now()
        time_delta = now_time - s_time
        print(time_delta)

if __name__ == '__main__':
    main()

実行結果は、以下のとおりです。

sh
pi@raspberrypi:~/Works/temp_logger/test $ python stopwatch.py
0:00:02.002138
0:00:04.004865
0:00:06.007525
0:00:08.009917
0:00:10.012274
0:00:12.014638
0:00:14.016988

ラズパイにて使用します。
使い方は省略。

0
0
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
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?