# 递归遍历"""
cur_path = r"C:\Users\Nic\Desktop\2018python\case"
# def find_file(path,sp=""):
# all_file = os.listdir(path)
# sp+=" "
# for file_name in all_file:
# abs_filpath=os.path.join(path, file_name)
# if os.path.isdir(abs_filpath):
# find_file(abs_filpath,sp)
# print(sp +"目录:", file_name)
# else:
# print(sp + "普通文件:", file_name)
# find_file(cur_path)
"""栈模拟(深度遍历)"""
# def getallRe(path):
# stack = []
# stack.append(path)
# while len(stack) !=0:
# dirPath = stack.pop()
# fileList = os.listdir(dirPath)
# for file_name in fileList:
# fileabsPath = os.path.join(dirPath, file_name)
# if os.path.isdir(fileabsPath):
# print("目录: ",file_name)
# stack.append(filePath)
# else:
# print("普通文件: ", file_name)
# getallRe(cur_path)
"""广度遍历,队列,同级目录处理"""
# def getfielQqe(path):
# queue = collections.deque()
# queue.append(path)
# while len(queue) !=0:
# dirpath = queue.popleft()
# filelist = os.listdir(dirpath)
# for file_name in filelist:
# fileabsPath = os.path.join(dirpath, file_name)
# if os.path.isdir(fileabsPath):
# print("目录: ",file_name)
# queue.append(fileabsPath)
# else:
# print("普通文件: ", file_name)
# getfielQqe(cur_path)