ID EN
Pathlib

exists

Python 3.11

Whether the path points to an existing file or directory:

Syntax

PYTHON
Path.exists()

Examples

Example 1
PYTHON
>>> Path('.').exists()
True
>>> Path('setup.py').exists()
True
>>> Path('/etc').exists()
True
>>> Path('nonexistentfile').exists()
False

See Also

exists()