Click here to Skip to main content
15,888,320 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I need to create an python code where the JSON language should be interpreted with it and that "raw samplecode.py" should be integrated with C# code and the output of the python code should be displayed on the C#.

What I have tried:

i already integrated the python code with the C# code by converting the raw python code to .exe format and gave that as an input file to the C# to execute it and i got the result too. But now i don't want to use the .exe file format as my input, i need to use raw python code to give as an input and that result should be displayed by using the C# code.
Posted
Updated 4-Feb-18 21:25pm

1 solution

Did you consider IronPython[^]?
 
Share this answer
 
Comments
aju6 6-Feb-18 0:48am    
I know that IronPython works good on this but i need to use only the normal python above version3. So,do u have any solution regarding that?

public static void Main()
{
Process process = new Process();
process.StartInfo.FileName = @"C:\\Users\arun.prabhu\\Documents\\sample_script.py";
process.StartInfo.FileName = @"C:\Users\arun.prabhu\Documents\testjsonres.exe";
process.StartInfo.UseShellExecute = false;
process.StartInfo.RedirectStandardOutput = true;
process.Start();


StreamReader reader = process.StandardOutput;
string output = reader.ReadToEnd();


Console.WriteLine(output);

process.WaitForExit();
process.Close();

Console.WriteLine("\n\nPress any key to exit.");
Console.ReadLine();
}

this code works fine with .exe but i need the .py code to be executed in the C# code.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900