get dir names python code example
Example 1: python get dir
import os
#full path
dir_path = os.path.dirname(os.path.realpath(__file__))
#current dir
cwd = os.getcwd()
Example 2: directory name python
# Directory name from path of file
import os
file_name = "/home/ubuntu/Project/demo.txt"
dir_name = os.path.dirname(file_name)
print(dir_name)