Python Interpreter Jython - execution of modules

我的梦境 提交于 2019-12-08 05:26:47

问题


Here's the link to the problem: Python Interpreter in Jython

The following was a potential solution:

    interp.exec("import os.path.abspath(__file__)/printTwice.py)");
    interp.exec("printTwice.print_twice('Adam')");

However it returned an error:

This returned the following error: Exception in thread "main" SyntaxError: ("mismatched input '(' expecting NEWLINE", ('', 1, 22, 'import os.path.abspath(file)/printTwice.py)\n'))


回答1:


interp.exec("import printTwice");
interp.exec("printTwice.print_twice('Adam')");

This should work.



来源:https://stackoverflow.com/questions/31756461/python-interpreter-jython-execution-of-modules

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!