from pathlib import Path Path('C:\Program Files').parent
from pathlib import Path path = Path(Path.cwd()) print(path.parent)