python3分割路径、文件名、扩展名

import os

filepath = '/home/xl/project/demo.txt'
(file_path, tempfilename) = os.path.split(filepath)
# file_path = '/home/xl/project'
# tempfilename = 'demo.txt'

(file_name, extension) = os.path.splitext(tempfilename)
# file_name = 'demo'
# extension = 'txt'

你可能感兴趣的:(python,python3获取路径,python3获取文件名,python3获取扩展名,python3分割路径,文件名,python3分割文件,扩展名)