Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

run python script from c#

using IronPython.Hosting;
using Microsoft.Scripting.Hosting;

private static void doPython()
{
    ScriptEngine engine = Python.CreateEngine();
    engine.ExecuteFile(@"test.py");
}

//You can get IronPython here : https://ironpython.net/
Comment

call python script from c#

private void run_cmd(string cmd, string args)
{
     ProcessStartInfo start = new ProcessStartInfo();
     start.FileName = "my/full/path/to/python.exe";
     start.Arguments = string.Format("{0} {1}", cmd, args);
     start.UseShellExecute = false;
     start.RedirectStandardOutput = true;
     using(Process process = Process.Start(start))
     {
         using(StreamReader reader = process.StandardOutput)
         {
             string result = reader.ReadToEnd();
             Console.Write(result);
         }
     }
}
Comment

run python from c#

string strCmdText;
string file;
file = "py.py"
strCmdText= "python3" + file;
System.Diagnostics.Process.Start("CMD.exe",strCmdText);
Comment

PREVIOUS NEXT
Code Example
Python :: reset index with pandas 
Python :: python get all ips in a range 
Python :: how to move a column in pandas dataframe 
Python :: how to take second largest value in pandas 
Python :: remove turtle 
Python :: Static Assets in Django 
Python :: python pandas cumulative sum of column 
Python :: boto3 with aws profile 
Python :: Resource punkt not found. Please use the NLTK Downloader to obtain the resource: 
Python :: internet explorer selenium 
Python :: fill na with mode and mean python 
Python :: how to auto update chromedriver selenium python 
Python :: on member leave event in discord.py 
Python :: numpy replace 
Python :: where my python modules 
Python :: playsound module in python 
Python :: export csv from dataframe python 
Python :: how to join a list of characters in python 
Python :: tqdm parallel 
Python :: how to find python version 
Python :: cosine interpolation 
Python :: Python find inverse of matrix 
Python :: python dictionary dot product 
Python :: youtube-dl python download to specific folder 
Python :: primes pytyhon 
Python :: converting datetime object format to datetime format python 
Python :: python ssh library 
Python :: python opens windows store 
Python :: urllib.request headers 
Python :: selenium how to handle element not found python 
ADD CONTENT
Topic
Content
Source link
Name
9+9 =