files = [f for f in os.listdir('.') if not os.path.isdir(f)]
这样你就可以做各种各样的事情
想要得到列表PDF文件,最近修改的第一
recentPDFs = [f for f in files if f[-4:] == '.pdf'] # Checks the file extension is pdf
recentPDFs.sort(key = lambda f: os.path.getmtime(f), reverse = True) # Sorts by time modified
excel文件怎么样,至少是最近创建的
recentExc = [f for f in files if f[-5:] == '.xlsx']
recentExc.sort(key = lambda f: os.path.getctime(f))
首先要做的是获得目录中所有文件(不包括文件夹)的列表
files = [f for f in os.listdir('.') if not os.path.isdir(f)]
这样你就可以做各种各样的事情
想要得到列表PDF文件,最近修改的第一
excel文件怎么样,至少是最近创建的
你现在可以看到模式了
相关问题 更多 >
编程相关推荐