python study demo

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

namespace PythonSample
{
    class Program
    {
        static void Main(string[] args)
        {
            //study1
            var scriptEngine = Python.CreateEngine();
            scriptEngine.Execute("print \"hello world\"");
            Console.WriteLine("press random key,and contiue...");
            Console.ReadLine();

            //study2
            ScriptRuntime py = Python.CreateRuntime();
            dynamic helloworld = py.UseFile("helloworld.py");
            for (int i = 0; i < 10; i++)
            {
                Console.WriteLine(helloworld.welcome("Employee #{0}"), i);
            }
            Console.ReadLine();
        }
    }
}

posted on 2010-07-17 16:27  chuncn  阅读(789)  评论(0编辑  收藏  举报

导航