python methods for separating filenames and paths and for separating filenames and suffixes
- 2020-12-21 18:06:40
- OfStack
Separate path and file name:
os.path.split()
Distinguish file names and suffixes:
os.path.splitext()
import os
file_path = "D:/test/test.py"
(filepath, tempfilename) = os.path.split(file_path)
(filename, extension) = os.path.splitext(tempfilename)