标签:desktop 处理 os.path pre list test import use tac
import os
import collections
#通过栈遍历目录(深度遍历)
def test(path):
stack=[]
stack.append(path)
#处理栈
while len(stack)!=0:
dirpath=stack.pop()
filelist=os.listdir(dirpath)
for filename in filelist:
fileAbsPath=os.path.join(dirpath,filename)
if os.path.isdir(fileAbsPath):
stack.append(fileAbsPath)
else:
print("文件:"+filename)
path=r"C:\Users\HP\Desktop\python基础知识"
test1(path)
标签:desktop 处理 os.path pre list test import use tac
原文地址:https://www.cnblogs.com/wfw001-2018/p/10290479.html