get path of parent directory python code example
Example 1: python get parent directory
import os.path
os.path.dirname('C:\Program Files')
Example 2: python get parent directory
from pathlib import Path
Path('C:\Program Files').parent
import os.path
os.path.dirname('C:\Program Files')
from pathlib import Path
Path('C:\Program Files').parent