-------队列-------
先进先出
import os,collections
def getAlDirRE(path):
# 获取队列对象
queue = collections.deque()
# 进队
queue.append(path)
# 循环遍历获取数据
while len(queue) != 0:
# 出对数据,先进先出
dirPath = queue.popleft()
# 找出所有文件
fileList = os.listdir(dirPath)
# 遍历获取所有的数据
for fileName in fileList:
# 绝对路径
fileAbspath =os.path.join(dirPath,fileName)
if os.path.isdir(fileAbspath):
print("目录:",fileName)
queue.append(fileAbspath)
else:
print("文件:",fileName)