首页 > 解决方案 > 检查 boost::python::tuple 的值为 None

问题描述

我正在尝试检查 boost::python::tuple 中的值是否为无。我有以下代码:

namespace py = boost::python;

py::list ls(inf.Module().attr("data_out"));

for (int i = 0; i < len(ls); i++){     
    py::tuple tuple = py::extract<py::tuple>(ls[i]);
    if (tuple[1] == py::object()){  /* Does not work */
        //do other stuff
    }
}

这给了我:

TypeError: No registered converter was able to produce a C++ rvalue of type unsigned int from this Python object of type NoneType

谁能帮我吗?

标签: pythonc++boost

解决方案


推荐阅读