首页 > 其他 > 详细

筛选最新生成的报告——sort

时间:2018-05-12 14:47:03      阅读:176      评论:0      收藏:0      [点我收藏+]
筛选出最新报告发送,返回报告路径

import os
def filePath(path):
return os.path.join(os.path.abspath(os.path.dirname(os.path.dirname(__file__))),path)
#所有报告都放在report下面
def reportPath():
#筛选出最新生成的报告
reportPath=filePath(‘report‘)
listDir=os.listdir(reportPath)
listDir.sort(key=lambda fn:os.path.getmtime(reportPath+"\\"+fn) if not os.path.isdir(reportPath+‘\\‘+fn) else 0)
file_new=os.path.join(reportPath,listDir[-1])
return file_new

筛选最新生成的报告——sort

原文:https://www.cnblogs.com/langhuagungun/p/9028575.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!