11. Pathlib Module
from pathlib import Path
path = Path("/home/user/documents")
print(path) # Output: /home/user/documentsfrom pathlib import Path
path = Path("example.txt")
print(path.exists()) # Output: True or Falsefrom pathlib import Path
dir_path = Path("new_folder")
dir_path.mkdir(exist_ok=True)
print(f"Directory created: {dir_path}")Last updated