public void callPython(){
try{
PythonInterpreter interpreter = new PythonInterpreter();
interpreter.execfile("track.py");
PyFunction func = interpreter.get("test_read",PyFunction.class);
String filepath = "loop.xml";
PyObject pyobj = func.__call__(new PyString(filepath));
Log.d(TAG, "callPython: "+pyobj.toString());
}catch (Exception e){
Log.d(TAG, "callPython: -----"+ e);
}
}
第一句创建对象时报错 MainActivity: callPython: -----java.lang.NullPointerException: Attempt to invoke virtual method 'org.python.core.PyType org.python.core.PyObject.getType()' on a null object reference