Skip to main content


Showing posts with the label python

IronPython and C#

What is IronPython
IronPython is an open-source implementation of the Python programming language which is tightly integrated with the .Net Framework.
IronPython can use the .Net Framework and python libraries,and other .NET languaages can use Python code just as easily
In this post I will show you how to call Python method in c#.
Create a new Console application and visual studio
Right click on the project and click on Manage Nuget Packages and search for IronPython

After installing IronPython import following namespaces
using Microsoft.Scripting.Hosting;

Right click on project and add new file and add following python code

def add(a,b):
return a+b

Open Program.cs file and add following code
using System; using System.Collections.Generic; using System.Linq; using System.Text; using Microsoft.Scripting.Hosting; namespace IronPython_Tut1 { class Program { staticvoid Main(string[] args) { //Create runtime ScriptRuntime runtime = I…

How to submit(Post) a webfrom from python/IronPython

In this post,I am going to show you how to post data from python to a webfrom from python. import urllib.parse import urllib.request url='' values={'keyword':'Void', 'data':'aspdotnetcodebook' } data=urllib.parse.urlencode(values) binary_data = data.encode('utf-8') req=urllib.request.Request(url,binary_data) response=urllib.request.urlopen(req) print (the_page)