Python 如何给 c 函数传递结构体参数

Python022

Python 如何给 c 函数传递结构体参数,第1张

 //test1.c# include <stdio.h># include <stdlib.h>struct Student

{    char name[30]    float fScore[3]

}void Display(struct Student su){    printf("-----Information------\n")    printf("Name:%s",su.name)    printf("Chinese:%.2f\n",su.fScore[0])    printf("Math:%.2f\n",su.fScore[1])    printf("English:%.2f",su.fScore[2])    printf("平均分数为:%.2f\n",(su.fScore[0]+su.fScore[1],su.fScore[2])/3)

}

网页链接

python ctypes 第一句话:

ctypes is a foreign function library for Python. It provides C compatible data types, and allows calling functions in DLLs or shared libraries. It can be used to wrap these libraries in pure Python.

没看到有说可以直接访问data。

你可以这样加这样的函数

int get_a()

{

    return a

}

再在python里面调用。