Get the File Name
Get the File Name From the File Path
Example 1: Using os module
import os
# file name with extension
file_name = os.path.basename('/root/file.ext')
# file name without extension
print(os.path.splitext(file_name)[0])fileExample 2: Using Path module
Last updated