我正在写申请书boost.python图书馆。我想把函数传递给python,它返回std::vector
。我有点小麻烦:
inline std::vector<std::string> getConfigListValue(const std::string &key)
{
return configManager().getListValue(key);
}
BOOST_PYTHON_MODULE(MyModule)
{
bp::def("getListValue", getListValue);
}
当我从python调用该函数时,我得到:
^{pr2}$我错过了什么?在
这是一个有点老的问题,但我发现,如果您明确要求按值返回,例如:
而不是
^{pr2}$Python为您进行转换(在编写这个答案时,我使用的是python2.7),不需要声明/定义转换器。在
@Tryskele公司
我使用以下实用程序函数从/到stl容器转换。平凡和函数说明了如何使用它们。我希望你能用它。在
你应该这样写一个转换器:
然后在模块中注册:
^{pr2}$相关问题 更多 >
编程相关推荐