环境:.net Framework 4.5.2 (当前使用)
python 3.7 (当前使用)
IronPython 2.7 (当前使用)
链接:https://pan.baidu.com/s/19Aj-dFPw0ybh33HeEp-GLQ
提取码:ltfc
我们使用.net调用python的时候,会发现有两种方法,第一个是用模块,第二个就是用控制台
我们接下来写的这个就是用模块调用,因为他们已经帮我们封装好了,非常方便.
在win Os 下面安装IronPython-2.7.8.msi
IronPython.dll
Microsoft.Scripting.dll
引用他们,他们在安装 IronPython-2.7.8.msi 目录下面
C#:
ScriptRuntime pyRuntime = Python.CreateRuntime();//创建Python运行时
dynamic py = pyRuntime.UseFile("C:/Users/Administrator/Desktop/ee.py");//执行这个PY文件
IronPython.Runtime.List a = py.Texts();//调用这个方法
Python:
#coding=utf-8
print("你好,我是测试文件")
def Texts():
print("测试")
return [6, 2, 3, 1, 5, 4]
# pass
是不是超级简单