我是 C 和 Python 的新手。这些天,我正在学习在 C 中嵌入 Python。当我从 C 中调用 Python 函数时,我想知道,我们如何将 C 结构传递给 Python?
提前非常感谢!
The cleanest thing to do is probably to create a new type and implement tp_getattr
, either returning the appropriate member of the struct or raising an exception depending on the argument passed.
这可能不是您想要的,但我们使用LCM在 c/c++、python、java 和 matlab 程序之间通过 udp 和多播共享 c 结构。这对于做机器人技术非常方便。