how do i get parent directory python 1

how do i get parent directory python

import os.path
os.path.dirname('C:\Program Files')

Here is what the above code is Doing:
1. It’s importing the os.path module.
2. It’s using the dirname() function from that module to get the directory name of the C:\Program Files directory.
3. It’s printing the result.

Similar Posts