【发布时间】:2015-05-21 21:36:26
【问题描述】:
我有以下 C# 代码,我从 C# 调用 python 脚本:
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Windows.Forms;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using IronPython.Hosting;
using Microsoft.Scripting.Hosting;
using IronPython.Runtime;
namespace RunPython
{
class Program
{
static void Main(string[] args)
{
ScriptRuntimeSetup setup = Python.CreateRuntimeSetup(null);
ScriptRuntime runtime = new ScriptRuntime(setup);
ScriptEngine engine = Python.GetEngine(runtime);
ScriptSource source = engine.CreateScriptSourceFromFile("HelloWorld.py");
ScriptScope scope = engine.CreateScope();
source.Execute(scope);
}
}
}
我无法理解每一行代码,因为我的 C# 经验有限。当我运行它时,我将如何更改此代码以便将命令行参数传递给我的 python 脚本?
【问题讨论】:
标签: c# python ironpython