Python遍历文件夹

import os

def walk_dir(targetdir,topdown=True):
    for root, dirs, files in os.walk(targetdir, topdown):
        for name in files:
            print(os.path.join(name))
        for name in dirs:
            print(os.path.join(name))

#Let's start here
walk_dir("D:\",fileinfo)

Leave a Reply

Your email address will not be published. Required fields are marked *

*