The parameters of the Os.walk directory traversal Os.walk are as follows:
Os.walk (Top, Topdown=true, Onerror=none, Followlinks=false)
which
-Top is the directory to traverse.
-Topdown represents whether to traverse from top to bottom or from bottom to top.
-OnError can be used to set the handler function when the error is facilitated (the function takes an instance of OSError as a parameter), and is set to NULL to not be processed.
-Followlinks Indicates whether you want to follow the link in the directory to continue the traversal, note that Os.walk does not log the directory that has been traversed, so it is possible to follow the link traversal to continue the call.
Os.walk returns a tuple of 3 elements that (root, dirs, files)
represents the traversed path name, the directory list under that path, and the list of files under that path. Note that directory lists and file lists are not specific paths and require a specific path (the path from root) os.path.join(root,dir)
os.path.join(root,dir)
.
Python Os.walk () walks out of folders and files in the current directory