[英]How to integrate python code with C# in Visual Studio 2019
Python code, which is executed on Google Colab and downloaded in.py file how to integrate it with C# code in Visual Studio 2019. On button click, Python code should execute in background and output should be displayed on WPF application. Python code, which is executed on Google Colab and downloaded in.py file how to integrate it with C# code in Visual Studio 2019. On button click, Python code should execute in background and output should be displayed on WPF application.
Python code can be executed in c# by IronPython library and via command prompt . Python 代码可以通过IronPython 库和命令提示符在 c# 中执行。 In IronPython I feel some issues.
在 IronPython 中我觉得有些问题。 So, I will suggest you to make a process and execute it by cmd.
所以,我会建议你制作一个流程并通过cmd执行它。 Here is the code to do so.
这是执行此操作的代码。
```Process proc = new Process();
ProcessStartInfo info = new ProcessStartInfo();
info.WindowStyle = ProcessWindowStyle.Normal;
info.FileName = "cmd.exe";
info.Arguments = "/C python code.py \""+arguments+"\"";
info.RedirectStandardOutput = true;
info.UseShellExecute = false;
info.CreateNoWindow = false;
proc.StartInfo = info;
proc.Start();
proc.WaitForExit();
string line = "";
while (!proc.StandardOutput.EndOfStream)
{
line += proc.StandardOutput.ReadLine();
}```
But you have to install all the libraries in PC first which must be overall in the PC not only in some folder.但是您必须首先在 PC 中安装所有库,这些库必须整体在 PC 中,而不仅仅是在某个文件夹中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.