【发布时间】:2015-12-02 05:38:11
【问题描述】:
我是 C 和 Python 的新手,我正在尝试将 C 函数 getText() 导入 Python,但我得到的只是数字
这是foo.c
#include <stdio.h>
const char * getText(void)
{
return "world hello";
}
const char * getText2(void)
{
return "hello world";
}
这是我在终端上的 python 代码
>>> import ctypes
>>> testlib = ctypes.CDLL('/home/user/dir/libfoo.so')
>>> testlib.getText()
743175865
我已经编译了共享对象并使用puts("Hello world") 对其进行测试,就像它在终端中显示的那样。
我确定我从 python 错误地访问了getText(),但我不知道是哪一个。任何建议或帮助将不胜感激
【问题讨论】:
标签: python c python-2.7 shared-libraries