参考代码
import os
file_path = "/var/www/project/logs/projectpom.log"
(filepath,tempfilename) = os.path.split(file_path)
(filename,extension) = os.path.splitext(tempfilename)
# filepath 文件路径
# tempfilename 文件名(全)
# filename 文件名
# extension 文件后缀、扩展名
REF
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)
https://www.cnblogs.com/lutt/p/12115755.html