import os
import collections
def getAllDirQU(path):
queue = collections.deque()
lstr = " "
#进队
queue.append(path)
while len(queue) !=0:
#出队
dirPath = queue.pop()
#找出所有的文件
filesList = os.listdir(dirPath)
for filename in filesList:
filePath = os.path.join(dirPath,filename)
if os.path.isdir(filePath):
print(lstr+"目录:"+filename)
queue.append(filePath)
else:
print(lstr+"普通文件:" + filename)
lstr +=" "
getAllDirQU(r"你要读取的文件夹")
python 判断某个文件夹的文件是文件还是文件夹
最新推荐文章于 2022-10-18 09:30:58 发布