os.listdir(path='.')
Return a list containing the names of the entries in the directory given by path. The list is in arbitrary order, and does not include the special entries '.'
and '..'
even if they are present in the directory.
path may be either of type str
or of type bytes
. If path is of type bytes
, the filenames returned will also be of type bytes
; in all other circumstances, they will be of type str
.
This function can also support specifying a file descriptor; the file descriptor must refer to a directory.
Note
To encode str
filenames to bytes
, use fsencode()
.
See also
The scandir()
function returns directory entries along with file attribute information, giving better performance for many common use cases.
Changed in version 3.2: The path parameter became optional.
New in version 3.3: Added support for specifying an open file descriptor for path.
Please login to continue.