Overview:
- The listdir() function returns a list of names of the entries present in a directory. Examples of entries include files, directories, links and others.
- The returned list of names does not include "." and ".." which represent the current directory and the parent directory.
Example:
# Example Python program that lists the names of # File path # Retrieve the names of entries in a directory # Print the entries |
Output:
['AntAndGrasshopper.txt', 'BaaBaa.txt', 'RowYourBoat.txt', 'Copy of BaaBaa.txt', 'Rain.txt', 'Wheels.txt', 'OneTwoBuckle.txt'] <class 'list'> |