5
これまでのところ、私はPythonエンジン(IronPython)を使用している単純なクラスを持っています。コードは大きく見えますが、それは本当にシンプルなので、ここで私の問題でより明確にするためにコピーします。IronPythonでC#で特定のPython関数を実行する
public class PythonInstance
{
ScriptEngine engine;
ScriptScope scope;
ScriptSource source;
public PythonInstance()
{
engine = Python.CreateEngine();
scope = engine.CreateScope();
}
public void LoadCode(string code)
{
source = engine.CreateScriptSourceFromString(code, Microsoft.Scripting.SourceCodeKind.Statements);
source.Compile();
}
public void SetVariable(string key, dynamic variable)
{
scope.SetVariable(key, variable);
}
public void RunCode()
{
source.Execute(scope);
}
public void CallFunction(string function)
{
//?????? no idea what to call here
}
}
ので、それは素晴らしい作品が、それは私だけが一度にすべてのPythonスクリプトを実行することができます...しかし、私は何をしたいのは、特定の関数を呼び出すことができるようにすることです。ここでは
コードですpythosスクリプトの中から。私の質問:ロードされたスクリプトで特定の関数を呼び出すにはどうすればよいですか?
私はいくつかの情報やチュートリアルを見つけようとしていましたが、残念ながら何も見つかりませんでした。
あなたはhttp://stackoverflow.com/questions/13231913/how-do-i-call-a-specific見てきました-method-from-a-python-script-in-cおよびhttp://stackoverflow.com/questions/7053172/how-can-i-call-ironpython-code-from-ac-sharp-app? –
@Simon firstはい、second no。リンクをありがとう、私は今それを読むでしょう。 – NewProger