python - 如何在 python 中使用 c 结构?

标签 python c wrapper

我有一个简单的 C 函数。

typedef struct {
    long unsigned int First;
    long unsigned int Second;
    int c;
} FRAGMENTS;

struct out {
    long unsigned int Four;
    FRAGMENTS fragments[10000];
};
struct out test() {
    struct out *out = (struct out *)malloc(sizeof(struct out));
    ...
    return *out
}

如何在 Python 中使用这个函数?将此结构转换为 python 对象(使用 python 包装器)的任何示例?

最佳答案

您是否已经将数据“保存在”Python 中(即来自网络或二进制文件)?比你使用 struct模块。

关于python - 如何在 python 中使用 c 结构?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7084726/

相关文章:

python - 如何扩展 str.isspace()?

c++-cli - C++/CLI 包装器不工作(LoaderLock 异常)

python - MySQLdb 显示警告时出现 UnicodeEncodeError

python - 在python中读取二进制数据文件进行分析

c++ - 使用非对称 key 的大文件加密/解密的C程序

c - 如何将从文件收集的字符串复制到新数组中以在 C 中进行控制台输出

linux - 为任意应用程序编写 I/O 包装器 (linux)

scala - 为什么值类仅限于 AnyVal?

python - 将状态传递给函数与调用类实例上的方法

c - 使用 strcpy 和等于运算符的字符串赋值