我有Visual Studio 2013,我的主窗体是用C#编写的。
我有一个python(3.7)脚本,有很多函数(使用类似Pandas、Numpy等库)
i、 e.对于来自.net UI的特定事件,应该调用python脚本并将该值作为参数从python返回到.net,反之亦然
-
铁蟒
-
.Net代码:
using Microsoft.Scripting.Hosting;
using IronPython.Hosting;
using IronPython.Runtime.Types;
using IronPython.Modules;
ScriptEngine py = IronPython.Hosting.Python.CreateEngine();
ScriptScope scope = py.ExecuteFile("Square.py");
dynamic Excel1 = scope.GetVariable("Excel")();
Excel1.ReadExcel("C:\\filePath\\abc.xlsx");
Python Script:
class Excel:
def ReadExcel(self, Path):
import pandas as pd
df = pd.read_excel (Path)
print (df)
return df
附加信息:没有名为pandas的模块