Python 查找指定文件夹下的所有路径
来源:互联网 发布:投资淘宝众筹怎么赚钱 编辑:程序博客网 时间:2024/05/21 06:36
import os.path as ospEnumTypes=(list,tuple)def _getsubdirs(prefdirs, others, maxdepth=5): """Returns the list of subdirectories of 'prefdirs' and 'others' up to 'maxdepth'. Note that 'prefdirs' appear at the beginning of the returned list, followed by their subdirectories, then 'others', and their subdirectories. """ new, dnew = [], {} # dnew exists only for performance (order must be kept in new) for dirs in (prefdirs, others): if not type(dirs) in EnumTypes: dirs=[dirs] dirs=[osp.realpath(i) for i in dirs if i<>''] for d in dirs: if dnew.get(d) is None: new.append(d) dnew[d] = 1 if maxdepth > 0: for d in dirs: level=len(d.split(osp.sep)) for root, l_dirs, l_nondirs in os.walk(d): lev=len(root.split(osp.sep)) if lev <= (level + maxdepth): if dnew.get(root) is None: new.append(root) dnew[root] = 1 else: del l_dirs[:] # empty dirs list so we don't walk needlessly return new
0 0
- Python 查找指定文件夹下的所有路径
- 读取指定文件夹下的所有图片之相对路径
- 读取指定文件夹下的所有图片之相对路径
- 输出指定文件夹下所有文件的路径
- TreeView 显示指定路径下的所有文件和文件夹
- php遍历指定路径下的所有文件和文件夹
- 指定文件路径下的当前层级的所有文件夹
- python 遍历指定文件夹下的所有文件内容
- Python如何读取指定文件夹下的所有图像
- python列出指定文件夹下所有给定后缀名的文件
- Python清空指定文件夹下所有文件的方法
- Python清空指定文件夹下所有文件的方法
- unity3d 根据指定的Assets下的文件夹路径 返回这个路径下的所有文件名
- unity3d 根据指定的Assets下的文件夹路径 返回这个路径下的所有文件名
- iOS小技巧 - 获取指定文件夹下的所有相对路径(包括子文件夹路径),并实现指定文件夹下的所有文件的全部移动
- Python获取文件夹下所有的文件路径列表
- 查找指定文件夹下的指定格式文件
- java删除指定路径下所有的文件, 及该文件夹里的所有文件夹,不包括该文件夹
- HTTP协议
- 编写一个函数实现n^k,使用递归实现
- android -- eclipse快捷键与技巧大全
- 将虚拟机导入到AWS
- 医学图像处理工具包ITK
- Python 查找指定文件夹下的所有路径
- JUnit4详解
- 自定义fact实现的四种方式介绍
- OpenCV2学习笔记(十三):基于SURF特征的图像匹配
- Android 字符间转换
- 【Scheme归纳】2 算数运算
- JDK各个版本的新特性jdk1.5-jdk8
- php 面向对象的一个简单实例
- 用Windows命令行管理AWS资源