这是我的 python脚本:
print("hello world")
theInput = input(">\n")
print("eingegeben: " + theInput + "\n")
我想从C#中调用这个脚本并输入它。但只有“你好世界”被打印出来。
C#中的调用函数内容:
Process proc = new Process();
proc.StartInfo.FileName = "python.exe";
proc.StartInfo.Arguments = "I:\\testskript.py";
proc.StartInfo.UseShellExecute = false;
proc.StartInfo.RedirectStandardInput = true;
proc.StartInfo.RedirectStandardOutput = true;
proc.StartInfo.CreateNoWindow = true;
proc.StartInfo.StandardOutputEncoding = Encoding.UTF8;
proc.Start();
proc.StandardInput.WriteLine("asdf");
string content = "";
while (true)
{
if (proc.StandardOutput.EndOfStream)
break;
content +=proc.StandardOutput.ReadLine() + "<br />";
}
webBrowser1.DocumentText = content; // the output goes to a webBrowers on the GUI
proc.Close();
return;