This is a memo for myself.
It's like a stopwatch for logging data such as temperature. Normally, the time is recorded, but this time it is a test program created to record the elapsed time.
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()
The execution result is as follows.
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
Used in Raspberry Pi. Usage is omitted.
Recommended Posts