小编But*_*ers的帖子

Python:在目录中查找扩展名为.MP3的最新文件

我试图在Python中找到最近修改过的(从此处开始'最新')特定类型的文件.我现在可以获得最新版本,但无论哪种类型都无关紧要.我想只获得最新的MP3文件.

目前我有:

import os

newest = max(os.listdir('.'), key = os.path.getctime)
print newest
Run Code Online (Sandbox Code Playgroud)

有没有办法修改它只给我最新的MP3文件?

python file-io

56
推荐指数
2
解决办法
4万
查看次数

标签 统计

file-io ×1

python ×1