import os defgci(filepath): #遍历filepath下所有文件,包括子目录 files = os.listdir(filepath) for fi in files: fi_d = os.path.join(filepath,fi) if os.path.isdir(fi_d): print(os.path.join(filepath, fi_d)) gci(fi_d) else: print(os.path.join(filepath,fi_d))#递归遍历/root目录下所有文件 gci('f:\\test')