C#調用Python腳本(Process)


使用命令運行python腳本

 

 

同樣的可以用代碼來實現

 1             Process p = new Process();
 2             string path = System.Web.HttpContext.Current.Server.MapPath("../Python/0610.py"); ;
 3             string sArguments = path;
 4             p.StartInfo.FileName = @"D:\tools\Anaconda3\python.exe"; 
 5             p.StartInfo.Arguments = sArguments;//python命令的參數
 6             p.StartInfo.UseShellExecute = false;
 7             p.StartInfo.RedirectStandardOutput = true;
 8             p.StartInfo.RedirectStandardInput = true;
 9             p.StartInfo.RedirectStandardError = true;
10             p.StartInfo.CreateNoWindow = true;
11             p.Start();

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM