Primary
os.listdir() ⚬|Documentation|1st|20251021183818-00-⌔
os — Miscellaneous operating system interfaces — Python 3 documentation#os.listdir
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. If a file is removed from or added to the directory during the call of this function, whether a name for that file be included is unspecified.path may be a path-like object. If path is of type
bytes(directly or indirectly through thePathLikeinterface), the filenames returned will also be of typebytes; in all other circumstances, they will be of typestr.This function can also support specifying a file descriptor; the file descriptor must refer to a directory.
Raises an auditing event
os.listdirwith argumentpath.Note: To encode
strfilenames tobytes, usefsencode().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.
Changed in version 3.3: Added support for specifying path as an open file descriptor.
Changed in version 3.6: Accepts a path-like object.
Printed 2026-06-28.
(echo:: @ ᯤ)
Link to original
Secondary
• • •