美文网首页
python调用一般c库函数的方法

python调用一般c库函数的方法

作者: doob_9117 | 来源:发表于2018-11-16 11:00 被阅读0次
#!/usr/bin/python
# -*- coding: UTF-8 -*-

#加载调用一般c库用到的模块
import ctypes

#加载c库到一个对象
lib = ctypes.cdll.LoadLibrary("/mnt/hgfs/VMsharedDocument/libcc.so")

#通过对象调用c库函数
lib.printhello()

上面python调用的c库如下

#include <stdio.h>

int printhello(){

    printf("hello\n");
    return 0;
}

相关文章

网友评论

      本文标题:python调用一般c库函数的方法

      本文链接:https://www.haomeiwen.com/subject/iqzixxtx.html