最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
Python实现遍历目录的方法【测试可用】
时间:2017-07-17 编辑:简简单单 来源:一聚教程网
代码如下 | 复制代码 |
# *-* coding=gb2312 *-* import os.path import shutil def traveltree(curPath,count): if not os.path.exists(curPath): return if os.path.isfile(curPath): fileName = os.path.basename(curPath) print '\t' * count + '├─' + fileName elif os.path.isdir(curPath): print '\t' * count + '├─' + curPath pathlist = os.listdir(curPath) for aa in pathlist: traveltree(curPath + "\\" + aa,count + 1 ) if __name__ = = '__main__' : traveltree( "C:\\py" , 1 ) |
运行效果图如下:
-
上一个: PHP实现随机生成水印图片功能
相关文章
- PHP导出数据超时的优化建议解读 10-31
- PHP之mysql位运算解析 10-31
- Laravel实现登录跳转功能解析 10-31
- php双向队列解读 10-31
- Laravel异常上下文解决教程 10-24
- php数组查询元素位置方法介绍 10-24