Answers for "get directory name in python without module"

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)
Posted by: Guest on March-26-2021
0

python get file name without dir

>>> os.path.basename('/path_name/1.log,/path_name/2.log')
'2.log'
Posted by: Guest on October-18-2021

Code answers related to "get directory name in python without module"

Python Answers by Framework

Browse Popular Code Answers by Language