python - Python(使用 ctypes)中是否有处理 C++ 结构中包含的向量的功能?
问题描述
我正在使用 ctypes 编写一个 Python 类来模仿 c++ 结构,需要帮助解决 c++ 结构中定义的 std::vector<> 。
我已经通过在字段声明中将它们声明为 c_'type' 来处理在 uint64_t、double、long、char 等类型的 c++ 结构中声明的一般变量,但我无法找到解决向量的方法.
C++
struct TypeSample
{
double _a
double _b
std::string toString() const
{....}
}
struct Sample
{
Sample()
:
_variableA(0),
_variableB(1)
{
}
uint64_t _variableA;
double _variableB;
std::vector<TypeSample> _variableC;
};
Python
from ctypes import *
class Sample(Structure):
_fields_ = [('_variableA',c_unit64),
('_variableB',c_double),
('_variableC',?????????),
]
任何帮助将不胜感激,感谢您抽出宝贵的时间
解决方案
推荐阅读
- javascript - 无法使用 nodejs 导出访问变量值?
- vba - 通过 VBA 在 PowerPoint 中更改语言仅在 macOS 中返回编译错误
- javascript - 如何附加一些带有循环的单选按钮并将其包裹在表单元素周围?
- ios - (已解决)Nativescript-plugin-firebase(“Swift 语言版本”(SWIFT_VERSION))
- python - 编写支持 TensorFlow CPU/GPU 的 Conda 环境文件的标准实践
- c++ - 试图理解通过引用传递 C++
- android - Libgdx Robovm:java.io.IOException:文件不是存档文件
- php - 如何使 PHP 注册错误出现在其专用输入框下方
- python - 如何使用 python 回调选择散景圆形字形?
- c# - 将 Entity Framework 6 项目分层