一切以官网为准:https://docs.python.org/3.6/library/ctypes.html
以下为参考:
1、 在python中调用C语言生成的动态库,
返回结构体指针 ,并进行输出!
mylib.c (动态库源代码)
- // 编译生成动态库: gcc -g -fPIC -shared -o libtest.so test.c
- #include
- #include
- #include
- typedef struct StructPointerTest
- {
- char name[20];
- int age;
- }StructPointerTest, *StructPointer;
- StructPointer testfunction() // 返回结构体指针
- {
- StructPointer p = (StructPointer)malloc(sizeof(StructPointerTest));