C# 调用批python 脚本

来源:互联网 发布:医疗竞价数据分析 编辑:程序博客网 时间:2024/05/17 17:55

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();
            }