def new_report(test_report): lists = os.listdir(test_report) # 列出目录的下所有文件和文件夹保存到lists lists.sort(key=lambda fn: os.path.getmtime(test_report + "/" + fn)) # 按时间排序 file_new = os.path.join(test_report, lists[-1]) # 获取最新的文件保存到file_new print(file_new) return file_new
python读取目录下最新的文件夹
最新推荐文章于 2024-03-09 07:22:07 发布