1.加命名空间
using
System.Diagnostics;
2.实现例子
try
... {
string myDocumentsPath = AppDomain.CurrentDomain.RelativeSearchPath;
myProcess.StartInfo.FileName =myDocumentsPath+ /views.py; //指定python文件
myProcess.StartInfo.Arguments = picname + " " + style; //带参数
myProcess.StartInfo.CreateNoWindow =true;
myProcess.StartInfo.UseShellExecute = false;
myProcess.Start(); //启动
//
myProcess.WaitForExit();
// Label1.Text = "Python script is successfully executed!";
}
catch (Exception er)
... {
Label1.Text = er.ToString();
}
... {
string myDocumentsPath = AppDomain.CurrentDomain.RelativeSearchPath;
myProcess.StartInfo.FileName =myDocumentsPath+ /views.py; //指定python文件
myProcess.StartInfo.Arguments = picname + " " + style; //带参数
myProcess.StartInfo.CreateNoWindow =true;
myProcess.StartInfo.UseShellExecute = false;
myProcess.Start(); //启动
//
myProcess.WaitForExit();
// Label1.Text = "Python script is successfully executed!";
}
catch (Exception er)
... {
Label1.Text = er.ToString();
}