Python2 查找某个目录下面的所有文件

def getfile(dir_file):
    baseUrl = dir_file
    fileList = []
    list = os.listdir(baseUrl)
     
    for i in range (0, len(list)):
        path = os.path.join(baseUrl,list[i])
        if os.path.isfile(path):
            fileList.append(list[i])
        else:
            pass
    return fileList

 

posted on 2019-06-26 11:23  lbxx  阅读(718)  评论(0编辑  收藏  举报

导航