这个问题折腾了我几个小时才弄明白怎么回事。。。
现在来简单解释一下
首先你需要一个java开发环境 这里使用eclipse
输入以下代码(*.py 路径按需求更改)
package t;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
public class Test {
public static void main(String[] args) throws IOException, InterruptedException {
// TODO 自动生成的方法存根
//Process proc = Runtime.getRuntime().exec("python F:\\pythonLabCodes\\lab3\\lab3_2.py");
try {
System.out.println("start");
String args1="python"+" "+"F:\\pythonLabCodes\\lab3\\lab3_2.py";
Process pr=Runtime.getRuntime().exec(args1);
BufferedReader in = new BufferedReader(new InputStreamReader(
pr.getInputStream()));
String line;
while ((line = in.readLine()) != null)