python使用ctypes调用C/C++
1. ctpes介绍
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.
2.使用ctypes调用C语言
python对于标准C的兼容做的相当不错,调用起来相对比较简单,下面给大家上案例
1. 创建一个adder.c文件,代码如下:
#include <stdio.h>
int add_int(int, int);
float add_float(float, float);
int add_int(int num1, int num2)
{
return num1 + num2;
}
float add_float(float num1, float num2)
{
return num1 + num2;
}
这是一个