【发布时间】:2010-10-06 08:42:07
【问题描述】:
从 cython 使用 C++ 标准 std::string 的最佳方式是什么?无论如何,最后一个 cython 发行版应该很容易,但我想知道为什么有 std::vector 的包装器而不是 std::string 的包装器......
【问题讨论】:
从 cython 使用 C++ 标准 std::string 的最佳方式是什么?无论如何,最后一个 cython 发行版应该很容易,但我想知道为什么有 std::vector 的包装器而不是 std::string 的包装器......
【问题讨论】:
Cython 0.16 includes wrappers for std::string,可以通过以下方式导入:
from libcpp.string cimport string
【讨论】:
Cannot convert 'string' to Python object
哎呀,这个问题已经在这里挂了几天了。最后我这样做了:
cdef extern from "string" namespace "std":
cdef cppclass string:
char* c_str()
这不是一个完整的解决方案,但它仍然可以解决问题。
【讨论】: