首页 > 技术文章 > c#调用python应用程序

duzhenwen 2020-05-12 13:36 原文

c#语言调用python编写的应用程序

windows

windows平台下,python打包后的应用程序为.exe程序

  using (Process myProcess = new Process())
                {
                    myProcess.StartInfo.UseShellExecute = false;
                    var guid = System.Guid.NewGuid().ToString();
                    var jsonfile = guid + ".json";
                    string jsonPath = ProjectPath + @"python\dist\json\" + jsonfile;
                    File.WriteAllText(jsonPath, jsonData);
                    myProcess.StartInfo.FileName = ProjectPath + @"python\dist\python\python.exe";
                    myProcess.StartInfo.Arguments = jsonfile + " " + resultTemlate + " "+flag + " "+Name;
                    myProcess.StartInfo.CreateNoWindow = true;
                    myProcess.StartInfo.ErrorDialog = false;
                    myPro

推荐阅读