如何使用Jython将Java列表传递给Python函数?
我试图将Java arraylist传递给Python函数。我正在犯错误
SEVERE: Servlet.service() for servlet [Faces Servlet] in context with path [/GEO_DM] threw exception [Cant instantiate class: com.ppts.bean.TriggerLawSocietyServiceBean.] with root cause java.lang.IllegalArgumentException: 'ofArrayType' must be compatible with existing array type of [Lorg.python.core.PyObject; see java.lang.Class.getName().
请参见下面我的java代码:
PythonInterpreter interpreter=new PythonInterpreter();
PyList pyList=new PyList(new ArrayList<>());
interpreter.execfile(getClass().getResourceAsStream("/com/ppts/propertiesfiles/sample_return_script.py"));
PyObject function=interpreter.get("returnSample");
PyObject result=function.__call__(new PyInteger(1),pyList,new PyDictionary());
progress=(int) result.__tojava__(Integer.class);
请参阅我的python代码:
def returnSample(var, list, dict):
print(var)
b=1
flag=True
print(list[0])
print(dict.keys())
return b
请不要看到用python完成的逻辑。 帮我把Arraylist传递给python函数
共 (0) 个答案