import time start = time.time() time.sleep(2) print(f"{format(time.time() - start, '.3f')}s") # 2.003s