2

我在 CPython 中使用 pythonnet,我设法安装它

import clr
clr.AddReference('Assembly')

确实有效。

在我的 C# 代码中,如果成员

public void Action(double Freq, double ChannelSpace, bool RefDoubler, bool RefD2, double RCounter, int DeviceIndex)
    {... //something is done
    }

如果我现在尝试做(在 Python 中):

from Assembly import Class
from System import Double, Int32,Boolean
Class.Action(Double(3000), Double(10), Boolean(False), Boolean(False), Double(10), Int32(0))

它总是抱怨并说:

TypeError: No method matches given arguments

为什么?

4

1 回答 1

3

由于该方法不是静态的,因此您必须使用该类的实例来调用它,即

from Assembly import Class
obj = Class()
obj.Action(...)
于 2014-10-17T12:44:53.363 回答