我在 windows7 上安装了 64 位 CPython 3.4。我使用 pythonnet 包(2.0.0.dev1)。我想实例化动作委托,但它给了我一个错误。
def display(num):
print("num=", num)
import clr
clr.AddReference("System")
import System
paction=System.Action[System.Int32](display)
我收到此错误:
() 中的 TypeError Traceback (最近一次调用最后一次) ----> 1 paction=System.Action[System.Int32](display) TypeError: unsubscriptable object
我想这是指定泛型的方式。
我已经检查了文档和这篇文章,但仍然没有看到问题。我也使用了 Overload 方法,但也没有帮助:
paction=System.Action.Overloads[System.Int32](display)
() 中的 TypeError Traceback (最近一次调用最后一次) ----> 1 paction=System.Action.Overloads[System.Int32](display) TypeError: No match found for constructor signature