直接执行python脚本
PythonInterpreter interpreter = new PythonInterpreter();
interpreter.exec("print("123")"); ///执行python脚本
执行python .py文件
PythonInterpreter interpreter = new PythonInterpreter();
InputStream filepy = new FileInputStream("/root/Desktop/demo.py");
interpreter.execfile(filepy); ///执行python py文件
filepy.close();
使用Runtime.getRuntime()执行脚本文件
Process proc = Runtime.getRuntime().exec("python /root/Desktop/demo.py");
proc.waitFor();