如何在C中调用Python函数? 谢谢!

如何在C中调用Python函数? 谢谢!

如何在C中调用Python函数?


[Copy to clipboard] [ - ]
CODE:
include <python2.4/Python.h>
int main(int argc, char *argv[])
{
        Py_Initialize();
        PyRun_SimpleString("from time import time,ctime "
                        "print 'Today is',ctime(time()) "
                        "print '^oo^'");
        Py_Finalize();
        return 0;
}

linux:~/code/python # cc c_python.c -lpython2.4
linux:~/code/python # ./a.out
Today is Fri Oct  7 14:59:39 2005
^oo^
非常感谢