defget_folder_state(folder): # 获取文件夹中所有文件的最后修改时间 state = {} for root, dirs, files in os.walk(folder): for file in files: path = os.path.join(root, file) state[path] = os.path.getmtime(path) return state
defexecute_command(command): # 执行命令 process = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) output, error = process.communicate() if process.returncode != 0: print(f"执行命令出错:{error.decode('utf-8')}") else: print(f"执行命令成功:{output.decode('utf-8')}")