IronPython初试

C#:

class Program
{
    static void Main(string[] args)
    {
        ScriptEngine engine = Python.CreateEngine();
        ScriptScope scope = engine.CreateScope();
        var sourceCode = engine.CreateScriptSourceFromFile("Main.py");
        sourceCode.ExecuteProgram();
        Console.WriteLine("Executed");
        Console.Read();
    }
}

 

 

Python:(Main.py)

def Foo():
    print "Hellow world"    

if __name__ == '__main__':
    Foo()

 

 

然后把Main.py的复制到输出目录配制成"始终复制",然后运行后打印结果:

你可能感兴趣的:(IronPython初试)