我使用Boosi::Python来回调C++侧的Python函数,Python函数可能有不同的参数,看起来像:
foo(int) ,
foo(int ,double),
foo(string , othertype,...) ,
< P>在我的C++程序中,我将Foo发送为升压::Python::对象,void Call(object foo)
{
//check each argument and assign value for example
int arg1=2;
string arg2="hehe";
.....
//then send above arguments to foo , but how to send?
foo(??);
}
现在我可以得到每个参数的名称并相应地给出值,但我的问题是:如何将值传递给foo
我使用boost::python::list或tuple收集数据,但不起作用,参数错误。 有人能帮我吗?多谢各位
您可以使用**参数: 因此,您可以将不同类型的多个参数作为dict类型传递
有关详细信息,请查看此链接:https://www.geeksforgeeks.org/args-kwargs-python/
相关问题 更多 >
编程相关推荐