c语言调用python 编译,使用c语言调用python内置函数--开发python帮助小程序--hpy

使用c语言调用python内置函数--开发python帮助小程序--hpy

#include #include "Python.h"

int main(int argc, char** argv)

{

char buf[512];

if (argc != 2) {

printf("luther.gliethttp提示:请使用py cmd查询帮助命令!\n");

return 0;

}

Py_Initialize();

if (!Py_IsInitialized())

return -1;

sprintf(buf, "help('%s')", argv[1]);

PyRun_SimpleString(buf);

}

1.安装python和对应c开发库

luther@gliethttp:~$ sudo apt-get install python2.5

luther@gliethttp:~$ sudo apt-get install python2.5-dev

2.编译程序

luther@gliethttp:~$ gcc luther_gliethttp_ptyhon.c -o hpy -I/usr/include/python2.5 -L/usr/lib/python2.5 -lpython2.5

luther@gliethttp:~$ sudo cp hpy /usr/local/bin

luther@gliethttp:~$ hpy dir

Help on built-in function dir in module __builtin__:

dir(...)

dir([object]) -> list of strings

Return an alphabetized list of names comprising (some of) the attributes

of the given object, and of attributes reachable from it:

No argument:  the names in the current scope.

Module object:  the module attributes.

Type or class object:  its attributes, and recursively the attributes of

its bases.

Otherwise:  its attributes, its class's attributes, and recursively the

attributes of its class's base classes.

(END)

3.好了python的help程序开发完成了,嘿嘿[luther.gliethttp]

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值