import os file_path = "D:/test/test.py"(filepath,tempfilename) = os.path.split(file_path) (filename,extension) = os.path.splitext(tempfilename)
Where:
filepath is the directory of the file, that is, D:/test
filename is the name of the file, that is, test
extension is the extension of the file, That is.py
For more articles related to [python][os] separation of file directories, file names and file suffixes, please pay attention to the PHP Chinese website!