12345678910111213141516171819 |
- # 获取文件名称
- from pathlib import Path
- def getInputFileName(filepath):
- if "/" in filepath:
- filename = filepath.split("/")[len(filepath.split("/")) - 1]
- return filename[0: filename.find(".")]
- elif "\\" in filepath:
- filename = filepath.split("\\")[len(filepath.split("\\")) - 1]
- return filename[0: filename.find(".")]
- else:
- return filepath
- #获取文件夹的父节点路径
- def getParentFolderPath(path):
- file_path = Path(path)
- parent_dir = file_path.parent
- return str(parent_dir)
|