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