0
2229
If you have a file name file1.txt in location /root/pythoneasy/, then the absolute path of the file is /root/pythoneasy/file1.txt
You can find the filename from the absoulute paths and relative paths as follows
import os
filename = os.path.basename('/root/pythoneasy/file1.txt')
print(filename) # Will print 'file1.txt'
filename = os.path.basename('../pythoneasy/file1.txt')
print(filename) # Will print 'file1.txt'
file1.txt
file1.txt
Comment here