#!/usr/bin/env python
# coding:UTF-8
"""
@version: python3.x
@author:曹新健
@contact: 617349013@qq.com
@software: PyCharm
@file: 广度遍历队列.py
@time: 2018/9/7 13:50
"""
import os
from collections import deque
def queueFiles(path):
queue = deque()
queue.append(path)
while True:
if len(queue) == 0:
break
popFile = queue.popleft()
#print(popFile)
for file in os.listdir(popFile):
newDir = os.path.join(popFile,file)
if os.path.isdir(newDir):
print(file)
queue.append(newDir)
else:
print(file)
if __name__ == "__main__":
queueFiles(r'E:\学习')