目录遍历--递归函数
#!/usr/bin/env python# coding:UTF-8"""@version: python3.x@author:曹新健@contact: 617349013@qq.com@software: PyCharm@file: 目录遍历.py@time: 2018/9/6 16:53"""import osdef getAll
·
#!/usr/bin/env python
# coding:UTF-8
"""
@version: python3.x
@author:曹新健
@contact: 617349013@qq.com
@software: PyCharm
@file: 目录遍历.py
@time: 2018/9/6 16:53
"""
import os
def getAllFiles(path,filler=' ',spfiller=''):
dirList = os.listdir(path)
spfiller += filler
print(spfiller)
for dirname in dirList:
curpath = os.path.join(path,dirname)
if os.path.isdir(curpath):
print(spfiller + dirname)
getAllFiles(curpath,spfiller=spfiller)
else:
print(spfiller + dirname)
if __name__ == "__main__":
getAllFiles(r'E:\学习')
更多推荐
已为社区贡献51条内容
所有评论(0)