天天看點

java執行jython

import org.python.util.PythonInterpreter;

public class JythonHelloWorld
{
    public static void main(String[] args)
    {
        PythonInterpreter pyInterp = new PythonInterpreter();
        try
        {
            pyInterp.exec("print('Hello Python World!')");
        }
        finally
        {
            pyInterp.close();
        }
    }
}
           

PythonInterpreter是python解釋器,需要下載下傳jython-standalone-2.7.2.jar

Downloads | Jython