#coding=utf8
import os,time
path = r"D:\cache\Adobe Photoshop CC 2015\AMT"
def dirsTree(startPath):
for root, dirs, files in os.walk(startPath):
level = root.replace(startPath, '').count(os.sep)
# 显示完整文件路径
# indent = str(root) + str(level )
## 用符号替代上一层路径
indent = '| ' * 1 * level + '|____'
print ('%s%s' % (indent, os.path.split(root)[1]))
# print (root,files)
dirsTree(path)
py 显示文件树
最新推荐文章于 2024-03-10 15:07:50 发布