FileUtils.py 571 B

12345678910111213141516171819
  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. else:
  11. return filepath
  12. #获取文件夹的父节点路径
  13. def getParentFolderPath(path):
  14. file_path = Path(path)
  15. parent_dir = file_path.parent
  16. return str(parent_dir)