我尝试在Java中使用PythonInterpreter,但是我不能在Intellij中导入org.python.util.PythonInterpreter包。所以下面的代码不能编译:
import org.python.util.PythonInterpreter;
import org.python.core.*;
public class SimpleEmbedded {
public static void main(String[] args) throws PyException {
PythonInterpreter interp = new PythonInterpreter();
System.out.println("Hello, brave new world");
interp.exec("import sys");
interp.exec("print sys");
interp.set("a", new PyInteger(42));
interp.exec("print a");
interp.exec("x = 2+2");
PyObject x = interp.get("x");
System.out.println("x: "+x);
System.out.println("Goodbye, cruel world");
}
}我试图下载jython zip库,但是Intellij无法识别这个库。对我有什么建议吗?
发布于 2020-04-13 19:55:51
https://stackoverflow.com/questions/61157199
复制相似问题