0
コマンドラインに「python」と入力するだけで、吐き出されたテキストを取得できないはずですか?Pythonスクリプトのstd出力を文字列としてコマンドラインに格納することはできません
try {
Process proc = Runtime.getRuntime().exec("python");
BufferedReader reader = new BufferedReader(new InputStreamReader(proc.getInputStream()));
String result = null;
while ((result = reader.readLine()) != null) {
PrintWriter out = resp.getWriter();
out.println("<div>" + result + "</div>");
}
} catch (IOException e) {
e.printStackTrace();
}
望ましい結果は次のようになります。python C:\Users\Me\HelloWorld.py
を実行
Python 3.4.4 (v3.4.4:737efcadf5a6, Dec 20 2015, 20:20:57) [MSC v.1600 64 bit (AM
D64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>>
を? –
何もありません。私もエラーはありません。 PythonコマンドをRuntimeから解釈したくないようです。 – santafebound
それは 'while'ループに詰まってしまったのでしょうか、それとも、すべて終了したのでしょうか? –