python遍历文件夹

import os

def list_dir_files(dir_abs):
    allfiles = []
    for root,dirs,files in os.walk(dir_abs):
        print('-----------------------------------')
        print('root:', root)
        print('dirs:', dirs)
        print('files:', files)
        for filespath in files:
            allfiles.append(os.path.join(root,filespath))
    return allfiles

  

posted on 2017-07-28 11:40  蚂蚁flow  阅读(121)  评论(0编辑  收藏  举报

导航