脚本专栏 
首页 > 脚本专栏 > 浏览文章

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

(编辑:jimmy 日期: 2025/5/16 浏览:3 次 )

如下所示:

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读取目录下最新的文件夹方法就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持。

上一篇:python3安装speech语音模块的方法
下一篇:对Python 语音识别框架详解
友情链接:杰晶网络 DDR爱好者之家 南强小屋 黑松山资源网 白云城资源网 网站地图 SiteMap