import threading
import time
# run函數
def run():
print(time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())) # 輸出當地時間
if time.strftime("%H:%M:%S", time.localtime()) == "15:57:00":
print("定時執行任務")
timer = threading.Timer(1, run) # 每秒執行
timer.start() # 啟動線程
run()