datetimeで作った時刻データでは、秒よりも細かい6桁の数字が含まれています。
単位はマイクロ秒 なので ミリ秒で出したいときは下記のように出せます。
1 2 3 4 5 6 7 8 9 10 11 12 13 |
import datetime import time # 1秒のsleep時間を正確に測定する time_init = datetime.datetime.now() time.sleep(1.0) time_delta = datetime.datetime.now() - time_init # 確認 print(time_delta) print(time_delta.seconds, "sec") print(time_delta.microseconds, "micro sec") print(time_delta.seconds * 1000 + time_delta.microseconds / 1000, 'msec') |
1 2 3 4 |
0:00:01.000511 1 sec 511 micro sec 1000.511 msec |
The following two tabs change content below.
Keita N
最新記事 by Keita N (全て見る)
- DDPG by gymnasium 15日目 - 2023年6月2日
- DDPG by gymnasium 14日目 - 2023年6月1日
- DDPG by gymnasium 13日目 - 2023年5月28日