随笔分类 - cpython
摘要:用C写一个函数,然后python调用C函数 add.c #include <stdio.h> int add(int a, int b){ int t; t = a + b; printf("%d\n",t); return t; } /*int main(){ add(1,2); return 0
阅读全文
摘要:spammodule.c #include <Python.h> static PyObject * spam_system(PyObject *self, PyObject *args) { const char *command; int sts; if (!PyArg_ParseTuple(a
阅读全文
摘要:calc.c#include <stdio.h> #include <Python.h> int add(int x, int y){ // C 函数 return x + y; } static PyObject *calc_add(PyObject *self, PyObject *args){
阅读全文
摘要:python可以用ctypes库调用C函数 1.生成.dll(windows下)或.so(linux下)文件 //pycall.c#include <stdio.h> #include <stdlib.h> int foo(int a, int b) { printf("you input %d a
阅读全文