Cython C ++和std :: string

时间:2010-10-06 08:42:07

标签: c++ python cython

从cython使用C ++标准std :: string的最佳方法是什么?最后的cython发行版应该会让它变得简单,但我想知道为什么有std :: vector的包装器而不是std :: string ......

2 个答案:

答案 0 :(得分:11)

Cython 0.16 includes wrappers for std::string,可以导入:

from libcpp.string cimport string

答案 1 :(得分:8)

哎呀,这个问题已经挂了好几天了。最后我做到了这一点:

cdef extern from "string" namespace "std":
    cdef cppclass string:
        char* c_str()

这不是一个完整的解决方案,但仍然可以做到这一点。