如何从Python脚本返回多个列表、值等到Java而不是一个单一的对象?目前我得到的是一个PyObject对象,其中包含了两个返回值,但我还没有想出如何在Java中将它们分开。
Python代码:
import random
def calculations():
res1 = [33, 13, 20, 34]
list = [1,3,5,7]
res2 = random.choices(list, k=10000)
return res1, res2
Java:
if(!Python.isStarted())
Python.start(new AndroidPlatform(getActivity()));
Python py = Python.getInstance();
PyObject obj = py.getModule("main").callAttr("calculations");
# How to extract the different objects from obj? Tried the following without success.
List<PyObject> totList = obj.call(0).asList();
int[] data3 = obj.call(1).toJava(int[].class);