How can we write code in Python to find all file system including files from root to each and every file of the current computer system.
相关问题
- how to define constructor for Python's new Nam
- streaming md5sum of contents of a large remote tar
- How to get the background from multiple images by
- Evil ctypes hack in python
- Correctly parse PDF paragraphs with Python
You can use the
os.walk
method. Here is an example:copied from http://www.tutorialspoint.com/python/os_walk.htm
See the full documentation: https://docs.python.org/2/library/os.html#os.walk
Refer to the
os
module.os.chdir(path)
changes the working dir.os.listdir()
lists all the directories in your working dir.If you wanna find all the directories of your current system, you need to iterate through your system using for example BFS search (https://en.wikipedia.org/wiki/Breadth-first_search).