使用Jython

时间:2017-12-29 04:43:09

标签: java python jython pythoninterpreter

我正在使用Jython尝试在我的Python文件中调用某个方法。 我收到这样的错误消息

[ERROR]  - Ambiguous method overloading for methodorg.python.util.PythonInterpreter#exec.
Cannot resolve which method to invoke for [null] due to overlapping prototypes between:
[class java.lang.String]
[class org.python.core.PyObject]

这是我的Java代码

static def visitPage(){
    PySystemState sys = Py.getSystemState();
    sys.path.append(new PyString(*The path to certain package*));
    PythonInterpreter interpreter = new PythonInterpreter(null, sys);
    interpreter.execfile(*Here's the path to the python file*);

    PyObject waitPage = interpreter.get("wait");
    println waitPage.toString();
    interpreter.exec(waitPage);
} 

打印结果为null。所以我认为我的问题是无法获得该方法。这是我的Python代码。我正在访问一个由PagePage类继承自LoginPage类的方法。

class LoginPage(PageObject):

所以我想知道是否还有其他方法可以使用Jython的Python解释器?

0 个答案:

没有答案