递归展示目录树
import os
allfiles=[]
def getAllFiles(path,level):
childFiles=os.listdir(path)
for file in childFiles:
filepath=os.path.join(path,file)
if os.path.isdir(filepath):
getAllFiles(filepath,level+1)
allfiles.append('\t'*level+filepath)
getAllFiles("路径",0)
for f in reversed(allfiles): #递归存进去是反的,reverse后再输出为正
print(f)