【发布时间】:2016-02-04 12:32:02
【问题描述】:
如何在 Python 中调用 IronPython 函数?有没有一种简单的方法来连接两者。我需要 IronPython 中没有的一整套适当的 Python 库和 Python .net 目前没有的最新 CLR 的灵活性。
到目前为止,我尝试的是编译 IronPython dll,但无法在 Python 中正确加载它。
我尝试让 IronPython n 可以从 Python 中调用
foo.py
def foo():
print 'hello world'
compile_ipy.py
import clr
clr.CompileModules("foo.dll", "foo.py")
我尝试从 Python 调用 Iron Python
call_ipy_from_py1.py
import ctypes
dll = ctypes.WindDLL('foo.dll')
dll.foo() # AttributeError: function 'foo' not found
call_ipy_from_py2.py
import ctypes
dll = ctypes.cdll.LoadLibrary('foo.dll')
dll.foo() # AttributeError: function 'foo' not found
【问题讨论】:
-
你能举个简单的例子吗?
-
@PeterWood 让我们从 Python 调用一个在 IronPython 中打印 hello world 的函数开始,我将包括我尝试过的内容。
标签: python .net interop ironpython python.net