Jython在android studio 中使用报错

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

阅读 1.7k
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题