PythonPython 測試程式碼片段執行時間測試 Python 的程式碼片段實際執行所需秒數1 2 3 4 5 6 7 import time start = time.perf_counter() # Do something end = time.perf_counter() elapsed = end - start print("elapsed:", elapsed) 參考資料time — Time access and conversions — Python 3 documentation