defget_full_path(path): if os.path.isabs(path): return path # 尝试对相对路径进行查找 # 查找当前目录 t = os.path.abspath(path) if os.path.exists(t): return t # 查找启动脚本所在目录 main_path = os.path.abspath(sys.argv[0]) t, _ = os.path.split(main_path) t = os.path.join(t, path) if os.path.exists(t): return t # 查找当前脚本所在目录 script_path = os.path.realpath(__file__) t, _ = os.path.split(script_path) t = os.path.join(t, path) if os.path.exists(t): return t raise FileNotFoundError(f"Can NOT find '{path}'.")
defaddClassPath(self, path): if path: ifisinstance(path, list) orisinstance(path, tuple): for e in path: jpype.addClassPath(get_full_path(e)) else: jpype.addClassPath(get_full_path(path))