当前位置:主页 > 软件编程 > Python代码 >

python查找指定文件夹下所有文件并按修改时间倒序排列的方法

时间:2021-03-16 10:22:22 | 栏目:Python代码 | 点击:

代码如下:

import os, glob, time

def search_all_files_return_by_time_reversed(path, reverse=True):
 return sorted(glob.glob(os.path.join(path, '*')), key=lambda x: time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(os.path.getctime(x))), reverse=reverse)

您可能感兴趣的文章:

相关文章