1:add.py

a = 100
b = 200
print (a + b)

2:测试代码

Process proc = Runtime.getRuntime().exec("python D:\\project\\python\\add.py");

            BufferedReader in = new BufferedReader(new InputStreamReader(proc.getInputStream()));
            String line = null;
            while ((line = in.readLine()) != null) {
                System.out.println(line);
            }
            in.close();
            proc.waitFor();

 

也可以使用jython-standalone工具包实现,详情见:https://www.jython.org/index

 

相关文章:

  • 2022-01-15
  • 2021-10-07
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-02-01
猜你喜欢
  • 2022-12-23
  • 2021-12-06
  • 2021-12-18
  • 2021-10-22
  • 2021-06-16
相关资源
相似解决方案