且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何从java运行python脚本?

更新时间:2023-10-21 13:13:58

你应该打电话给 p.waitFor(); 以便您的Java程序在外部进程执行完之后才会继续运行。

You should perhaps call p.waitFor(); so that your Java program doesn't move on until after the external process has finished executing.

Update 1:还要确保你正在读取 p.getErrorStream() p.getInputStream()$ c中的所有字节$ C>。如果不这样做可能会导致此过程停止。

Update 1: Also make sure you are reading all the bytes out of p.getErrorStream() and p.getInputStream(). Failure to do so may hang the process.

更新2:您可能还需要检查错误代码的进程返回代码。进程返回代码通过 waitFor()的返回值访问。

Update 2: You may also want to check the process return code for an error code. The process return code is accessed via waitFor()'s return value.