How do I get the parent directory in Python? code example Example: How do I get the parent directory in Python? from pathlib import Path Path(Path.cwd()).parent