可以使用jython
方法参考如下
PythonInterpreter interpreter = new PythonInterpreter();
interpreter.execfile("uar/local/xxx.py");
//pyFunction :py中方法名
PyFunction func = (PyFunction)interpreter.get("pyFunction",PyFunction.class);
Integer a = 1
Integer b = 2
// py中方法传参
PyObject pyobj = func.__call__(new PyInteger(a), new PyInteger(b));
System.out.println("anwser = " + pyobj.toString());
本回答被提问者采纳