import os
import time
import platform
import subprocess
def open_folder(path):
"""根据操作系统打开文件夹"""
if platform.system() == "Windows":
os.startfile(path)
elif platform.system() == "Darwin":
subprocess.run(["open", path])
else:
subprocess.run(["xdg-open", path])
def countdown(minutes, folder_path):
"""带进度显示的分钟级倒计时"""
total_seconds = minutes * 60
try:
for i in range(total_seconds, 0, -1):
mins, secs = divmod(i, 60)
time_display = f"{mins:02d}分{secs:02d}秒"
time.sleep(1)
print("\n倒计时完成!正在打开文件夹...")
open_folder(folder_path)
except FileNotFoundError:
print(f"错误:找不到文件夹路径 '{folder_path}'")
except Exception as e:
print(f"发生未知错误:{str(e)}")
ttl=0
if __name__ == "__main__":
while(1):
COUNTDOWN_MINUTES = input('COUNTDOWN_MINUTES:')
COUNTDOWN_MINUTES = int(COUNTDOWN_MINUTES)
if COUNTDOWN_MINUTES >= 10:
ttl=ttl+20
TARGET_FOLDER = url
print(f"倒计时开始,将在 {COUNTDOWN_MINUTES} 分钟后打开文件夹...")
print(f"已用时{ttl}min")
print(time.strftime("%H:%M:%S", time.localtime(time.time())))
countdown(COUNTDOWN_MINUTES, TARGET_FOLDER)