python遍历目录树代码

清华大佬耗费三个月吐血整理的几百G的资源,免费分享!....>>>

from os.path import basename, isdir
from os import listdir

def traverse(path, depth=0):
    print depth* '| ' + '|_', basename(path)
    if(isdir(path)):
        for item in listdir(path):
            traverse(path+'/'+item, depth+1)

if __name__ == '__main__':
    traverse('./')