python递归读取目录列表

import os


def listdirs(base):
    for line in os.listdir(base):
        fullpath = os.path.join(base,line)
        if os.path.isdir(fullpath):
            listdirs(fullpath)
        elif os.path.isfile(fullpath):
            print fullpath

base = r'C:\Program Files\SogouInput\Components'
listdirs(base)
    

 

posted @ 2014-02-10 14:19  silence.li  阅读(653)  评论(0编辑  收藏  举报