在Python中,以最快的方式在具有特定扩展名的目录中构建文件列表 [英] In Python, fastest way to build a list of files in a directory with a certain extension

查看:157
本文介绍了在Python中,以最快的方式在具有特定扩展名的目录中构建文件列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在GNU / Linux系统上的Python中,递归扫描所有 .MOV .AVI 文件,并将它们存储在列表中?

解决方案

您可以使用os.walk()进行recuresive walking和glob.glob()或fnmatch.filter匹配:

检查 answer


In Python on a GNU/Linux system, what's the fastest way to recursively scan a directory for all .MOV or .AVI files, and to store them in a list?

解决方案

You can use os.walk() for recuresive walking and glob.glob() or fnmatch.filter() for file matching:

Check this answer

这篇关于在Python中,以最快的方式在具有特定扩展名的目录中构建文件列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆