OS module in Python provides functions for interacting with the operating system. OS comes under Python’s standard utility modules. This module provides a portable way of using operating system dependent functionality.
os.scandir() method in Python is used to get an iterator of os.DirEntry objects corresponding to the entries in the directory given by specified path.
The entries are yielded in arbitrary order and special entries ‘.’ and ‘..’ are not included.
Syntax: os.scandir(path = ‘.’)
path: A path-like object representing the file system path. This specify the directory to be scanned. If path is not specified then current working directory is used as path.
A path-like object is a string or bytes object which represents a path.
Return Type: This method returns an iterator of os.DirEntry objects corresponding to the entries in the given directory.
Files and Directories in '/home': GeeksforGeeks Videos Downloads Pictures Documents sample.txt Public Desktop Images R
- Difference between Method Overloading and Method Overriding in Python
- class method vs static method in Python
- Python | os.dup() method
- Python | next() method
- Python | set() method
- Python - PyTorch abs() method
- Python PIL | ImageOps.fit() method
- Python - PyTorch exp() method
- Python - PyTorch add() method
- Python | os.open() method
- Python | os._exit() method
- Python | os.WEXITSTATUS() method
- Python | os.mkdir() method
- Python | Tensorflow sin() method
- Python | os.remove() method
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.