def find_latest_modified_file(self, folder_path): # 给定一个文件夹路径,找到最近修改的文件 files = [os.path.join(folder_path, file) for file in os.listdir(folder_path) if file.split('/')[-1][0] == 'm'] # 获取文件夹下以'm'开头的文件路径列表 nx, ny = 4096, 4096 file = '' # 初始化变量nx, ny为4096,file为空字符串 for i in files: try: x, y = i.split('_')[-3:-1] # 从文件路径中获取文件名,再根据文件名格式获取x, y坐标信息 x, y = int(x), int(y) if x < nx or y < ny: nx, ny = x, y file = i # 如果该文件的x或y坐标小于之前记录的文件,则更新nx, ny和file except: pass # 如果解析文件名失败,则跳过该文件 return file # 返回最近修改的文件路

def find_latest_modified_fileself folder_path files = ospathjoinfolder_path file for file in oslistdirfolder_path if filesplit-10 == m nx ny = 4096 4096 file = for i in fi

原文地址: https://www.cveoy.top/t/topic/fFzx 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录