FileUtils.py 535 B

1234567891011121314151617
  1. # 获取文件名称
  2. from pathlib import Path
  3. def getInputFileName(filepath):
  4. if "/" in filepath:
  5. filename = filepath.split("/")[len(filepath.split("/")) - 1]
  6. return filename[0: filename.find(".")]
  7. elif "\\" in filepath:
  8. filename = filepath.split("\\")[len(filepath.split("\\")) - 1]
  9. return filename[0: filename.find(".")]
  10. #获取文件夹的父节点路径
  11. def getParentFolderPath(path):
  12. file_path = Path(path)
  13. parent_dir = file_path.parent
  14. return str(parent_dir)