import os
root = 'C:\\Users\\XIAOWEI\\Desktop\\工作文档\\python'
def tree(root, filters=['__pycache__', 'pyc','build','dist'], depth=0, prefix=' '):
print(prefix*depth + '▶' +os.path.basename(root))
depth+=1
dirFiles = os.listdir(root)
for df in dirFiles:
if not df.split('.')[-1] in filters:
path = os.path.join(root, df)
if os.path.isdir(path):
tree(path, filters, depth, prefix)
else:
print(prefix*depth + df)
tree(root)