Pathlib exists
- exists
from pathlib import Path
file = Path(__file__)
print(file.exists()) # True
file = Path("hello.txt")
print(file.exists()) # False
folder = Path(".")
print(folder.exists()) # True
Press ← or → to navigate between chapters
Press S or / to search in the book
Press ? to show this help
Press Esc to hide this help
from pathlib import Path
file = Path(__file__)
print(file.exists()) # True
file = Path("hello.txt")
print(file.exists()) # False
folder = Path(".")
print(folder.exists()) # True