我有以下代码(只是一个测试):
var engine = Python.CreateEngine();
var runtime = engine.Runtime;
try
{
dynamic test = runtime.UseFile(@"d:\test.py");
test.SetVariable("y", 4);
test.SetVariable("client", UISession.ControllerClient);
test.Simple();
}
catch (Exception ex)
{
var eo = engine.GetService<ExceptionOperations>();
Console.WriteLine(eo.FormatException(ex));
}
但我想改为从字符串加载脚本。