欢迎使用Markdown编辑器写博客
本Markdown编辑器使用StackEdit修改而来,用它写博客,将会带来全新的体验哦:
代码块
python遍历本地文件目录,例如:
import os
import collections
def getAllDirQueue(path):
queue = collections.deque()
queue.append(path)
while len(queue) != 0:
dirpath = queue.popleft()
filelist = os.listdir(dirpath)
for listname in filelist:
fileabspath = os.path.join(dirpath, listname)
if os.path.isdir(fileabspath):
print("目录:"+listname)
queue.append(fileabspath)
else:
print("普通文件"+fileabspath)
getAllDirQueue("D:\MySQL")