【发布时间】:2019-08-25 01:10:22
【问题描述】:
当我尝试运行此代码时,我不断收到错误 System.ComponentModel.Win32Exception: The specified executable is not a valid application for this OS platform.。
似乎myProcess.Start() 行是问题所在。
谁能帮帮我。
string python = @"C:\Users\mk\Desktop\A.py";
// python app to call
string myPythonApp = "sum.py";
// dummy parameters to send Python script
int x = 2;
int y = 5;
// Create new process start info
ProcessStartInfo myProcessStartInfo = new ProcessStartInfo(python);
// make sure we can read the output from stdout
myProcessStartInfo.UseShellExecute = false;
myProcessStartInfo.RedirectStandardOutput = true;
// start python app with 3 arguments
// 1st arguments is pointer to itself,
// 2nd and 3rd are actual arguments we want to send
myProcessStartInfo.Arguments = myPythonApp + " " + x + " " + y;
Process myProcess = new Process();
// assign start information to the process
myProcess.StartInfo = myProcessStartInfo;
Console.WriteLine("Calling Python script with arguments {0} and {1}", x, y);
// start the process
myProcess.Start();
}
}
}
【问题讨论】:
标签: c# python visual-studio