import os file_path = "/var/www/project/logs/projectpom.log" (filepath,tempfilename) = os.path.split(file_path) (filename,extension) = os.path.splitext(tempfilename) print("文件路径 ",filepath) print("文件名(全) ",tempfilename) print("文件名 ",filename) print("文件后缀 ",extension)