Windowsには、stdinから読み取るプログラム(prog.exe)があります。Pythonでは、文字列をそのstdinへの入力としてパイプ処理したいと思います。どうやってするか?
何かのようなもの:
subprocess.check_output("echo {0} | myprog.exe".format(mystring))
または(引数をリストにするため)
subprocess.check_output("echo {0} | myprog.exe".format(mystring).split())
動作しないようです。それは私に与えました:
WindowsError: [Error 2] The system cannot find the file specified
また、StringIO(ファイルのようなオブジェクト)で「stdin」キーワードargを使用しようとしました
subprocess.check_output(["myprog.exe"], stdin=StringIO(mystring))
それでも運がない-check_outputはStringIOでは機能しません。