1. 首页
  2. 数据库
  3. 其它
  4. python读取目录下最新的文件夹方法

python读取目录下最新的文件夹方法

上传者: 2021-02-01 03:26:49上传 PDF文件 27.41KB 热度 24次
如下所示: 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读
下载地址
用户评论