参考:https://www.jb51.net/article/258341.htm
os.walk本身已经是遍历读取,包含所有的子文件(夹)
path = u'.' #文件路径 def newWalkFile2(file):
#main_dir 当前路径,sub_dir_list 当前路径下的子文件夹是个数组,sub_file_list 当前路径下具体文件 for main_dir, sub_dir_list, sub_file_list in os.walk(file): for f in sub_file_list: print f if __name__ == "__main__": newWalkFile2(path)
标签:__,遍历,sub,Python,list,文件夹,file,main,dir From: https://www.cnblogs.com/Cxiangyang/p/17374724.html