-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCsCallPython.cs
More file actions
23 lines (21 loc) · 842 Bytes
/
Copy pathCsCallPython.cs
File metadata and controls
23 lines (21 loc) · 842 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
//关键代码 不是全部逻辑 也不是只有c#才能调用 这是个例子
ProcessStartInfo startInfo = new ProcessStartInfo
{
FileName = PyExePath, // Python解释器的执行文件名
Arguments = overwrite ? $"{pyPath} {imagePath} {cutType} {imagePath}" : $"{pyPath} {imagePath} {cutType}",
RedirectStandardOutput = true,
UseShellExecute = false,
CreateNoWindow = true
};
using Process process = new Process();
process.StartInfo = startInfo;
process.OutputDataReceived += (sender, e) =>
{
if (!string.IsNullOrEmpty(e.Data))
{
Debug.Log("输出数据:" + e.Data);
}
};
process.Start();
process.BeginOutputReadLine();
process.WaitForExit();