Java使用CMD运行python程序
先将python.exe配置到环境变量Process proc;
try {
try {
proc = Runtime.getRuntime().exec("python d://test.py");
} catch (IOException e) {
throw new RuntimeException(e);
}
BufferedReader in = new BufferedReader(new InputStreamReader(proc.getInputStream()));
String line = null;
while ((line = in.readLine()) != null) {
System.out.println(line);
}
in.close();
proc.waitFor();
} catch (IOException e) {
e.printStackTrace();
} catch (InterruptedException e) {
e.printStackTrace();
} 谢谢分享 谢谢分享,已回复
页:
[1]