【发布时间】:2010-10-18 16:44:27
【问题描述】:
考虑下面的代码:
ScriptRuntimeSetup setup = Python.CreateRuntimeSetup(null);
ScriptRuntime runtime = new ScriptRuntime(setup);
ScriptEngine engine = Python.GetEngine(runtime);
ScriptScope scope = engine.CreateScope();
scope.SetVariable("message", "Hello, world!");
string script = @"print message";
ScriptSource source = scope.Engine.CreateScriptSourceFromString(script, SourceCodeKind.Statements);
source.Execute();
此代码产生以下异常:
Microsoft.Scripting.Runtime.UnboundNameException 未处理 Message="name “消息”未定义”
我错过了什么?
【问题讨论】:
标签: c# ironpython