大佬教程收集整理的这篇文章主要介绍了c – 查找boost python对象的类型,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
boost::python::object module_ = boost::python::import("..libName"); boost::python::object result_ = module_.attr("..functionName")(arg1,arg2,...); //suppose if the result is int,int a_ = boost::python::extract<int>(result_);
从上面的代码片段,我想知道的是如果有办法找到类型
提取之前的结果.在上面的代码中,result_可以是任何类型,如list,tuple …
std::vector<std::string> list_to_vector(boost::python::list& l) { for (int i = 0; i < len(n); ++i) { boost::python::extract<boost::python::object> objectExtractor(l[i]); boost::python::object o=objectExtractor(); std::string object_classname = boost::python::extract<std::string>(o.attr("__class__").attr("__name__")); std::cout<<"this is an Object: "<<object_classname<<std::endl; } ................................................... ................................................... }
它适用于我
以上是大佬教程为你收集整理的c – 查找boost python对象的类型全部内容,希望文章能够帮你解决c – 查找boost python对象的类型所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。