Boost.Python.ArgumentE

2024-05-19 17:07:13 发布

您现在位置:Python中文网/ 问答频道 /正文

我最近在学习python,当我调用功能。希望有人可以帮我。 在C++中:

typedef struct   
{  
    char words[10];  
}keywords; 
typedef struct   
{  
    keywords *kws;  
    unsigned int len;  
}outStruct;
int test(outStruct *o)  
{  
    unsigned int i = 2;  
    o->kws = (keywords *)malloc(sizeof(unsigned char) * 10 * i);  
    strcpy(o->kws[0].words, "The First Data");  
    strcpy(o->kws[1].words, "The Second Data");  

    o->len = i;  
    return 1;
}  
BOOST_PYTHON_MODULE(pyTest)
{
    def("test", test); 
} 

python语言:

^{pr2}$

错误: Boost.Python.ArgumentError:Python参数类型 你好。测试(你好,货物对象) 类外结构(结构):
关键字('Kw>,长度U)

我在谷歌上搜索了几个小时,没有找到任何好的解决方案。 我想用python得到结构。 谢谢你的帮助。在


Tags: thetestdatalen结构structintwords