Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Diagnostics;
- class Program
- {
- static void Main()
- {
- // Create a Process object
- using (Process process = new Process())
- {
- // Set the Python interpreter as the filename
- process.StartInfo.FileName = "python";
- // Specify the path to your Python script as arguments
- process.StartInfo.Arguments = "C:\\Path\\to\\your\\script.py";
- // Configure process settings
- process.StartInfo.UseShellExecute = false; // Don't use the operating system shell
- process.StartInfo.RedirectStandardOutput = true; // Redirect standard output
- process.StartInfo.CreateNoWindow = true; // Don't create a window for the process
- // Start the process
- process.Start();
- // Read the standard output
- string output = process.StandardOutput.ReadToEnd();
- // Wait for the process to exit
- process.WaitForExit();
- // Process the output
- Console.WriteLine(output);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement