如何在Cython中最好地使用C++标准库std :: string?虽然最新的Cython发行版应该会使它变得容易,但我想知道为什么有std :: vector的包装器,而没有std :: string的包装器...
Cython 0.16 包含了 std::string 的封装器, 可以通过以下方式导入:
from libcpp.string cimport string
糟糕,这个问题已经悬挂在这里几天了。最后我做了以下操作:
cdef extern from "string" namespace "std":
cdef cppclass string:
char* c_str()
虽然这并不是一个完整的解决方案,但它仍然能够实现所需功能。