文件目录tree显示,python
2024-08-26 02:29:49
#/usr/bin/python
import os
def travelTree(currentPath, count=0):
if not os.path.exists(currentPath):
print "no current Path"
return
if os.path.isfile(currentPath):
fileName = os.path.basename(currentPath)
print " "*count + "|_ "+fileName
elif os.path.isdir(currentPath):
#print currentPath
print " "*count + "|_ "+currentPath
pathList = os.listdir(currentPath)
for eachPath in pathList:
travelTree(currentPath + '/' + eachPath, count + 1)
else :
print "\n"
return
travelTree('/Users/liyi/Desktop')
#travelTree('/Users/liyi/Desktop/test.sh', 1)
最新文章
- HeapSort 堆排序 基于伪代码实现
- ANT build.xml文件详解
- Myeclipse加载maven
- lvs简单配置
- Spket在Eclipse/MyEclipse下的安装和配置支持Ext(图文教程)
- MVC 自定义AuthorizeAttribute实现权限管理
- Sprite Kit编程指南(1)-深入Sprite Kit
- Python之路:迭代器和yield生成器
- TS流文件
- Thinking in scala (7)---- f(n)=f(n-1)+2f(n-2)+3f(n-3)
- [偏序关系与CDQ分治]【学习笔记】
- [dev][crypto][strongswan] 有关strongswan的forward policy的源码分析
- WinForm 绑定到嵌套对象上的属性
- ubuntu 下安装mulval
- Diverse Garland CodeForces - 1108D (贪心+暴力枚举)
- BZOJ3456 城市规划 【多项式求ln】
- VMware安装windows10系统
- Docker镜像、容器剖析
- TPL DataFlow初探(一)
- SqlServer基础语法(二)