parent directory name python code example
Example 1: python get parent directory
import os.path
os.path.dirname('C:\Program Files')
Example 2: How do I get the parent directory in Python?
from pathlib import Path
Path(Path.cwd()).parent
import os.path
os.path.dirname('C:\Program Files')
from pathlib import Path
Path(Path.cwd()).parent