Python Program to Get the File Name From the File Path (Using Path module)
from pathlib import Path
print(Path('/root/file.ext').stem)
Output
file
from pathlib import Path
print(Path('/root/file.ext').stem)
Output
file