python recursive directory traversal

OS Import 

DEF getAllDirRE (path, SP = ""):
# get all the files in the current directory
filesList the os.listdir = (path)
# process each file
SP + = ""
for fileName in filesList:
# determines whether the path ( absolute path)
fileAbsPath = os.path.join (path, fileName)
IF os.path.isdir (fileAbsPath):
Print (SP + "directory:", fileName)
# recursive call
getAllDir (fileAbsPath, SP)
the else:
Print ( sp + "Trivial file:", fileName)
getAllDirRE("D:\python")

Guess you like

Origin www.cnblogs.com/pygo/p/12275856.html