This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Diagnostics; | |
using System.IO; | |
using System.Linq; | |
using System.Text; | |
using System.Threading.Tasks; | |
namespace SamplePythonCall | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
run_cmd(); | |
} | |
static private void run_cmd() | |
{ | |
string fileName = @"C:\Users\ochi\Documents\temp\test.py"; | |
ProcessStartInfo start = new ProcessStartInfo(); | |
start.FileName = "python";//またはPython.exeのフルパス | |
start.Arguments = fileName; | |
start.UseShellExecute = false; | |
start.RedirectStandardOutput = true; | |
using (Process process =Process.Start(start)) | |
{ | |
using (StreamReader reader = process.StandardOutput) | |
{ | |
string result = reader.ReadToEnd(); | |
Console.Write("C#>"+result); | |
} | |
} | |
Console.ReadLine();//終了まち(enterで終了) | |
} | |
} | |
} |
0 件のコメント:
コメントを投稿