分类: LINUX
2013-12-20 17:27:44
//#======================================================== //# author:ago //# 2012/08/24 19:26:57 //#========================================================
#include "python_lib/Python.h"
#include
#pragma comment(lib,"python27_d.lib")
int main(int argc, char *argv[])
{
Py_Initialize();
//PyRun_SimpleString("import sys");
//PyRun_SimpleString("sys.path.append('./')");
PyObject* pName = PyString_FromString("main");
//python 文件的名字
PyObject* pModule = PyImport_Import(pName);
if ( !pModule )
{
MessageBox(NULL, ("找不到main.py"), ("提示"), MB_OK);
return 1;
}
PyObject* pDict = PyModule_GetDict(pModule);
PyObject* pFunc = PyDict_GetItemString(pDict, "test");
//python 文件中函数名:test
PyObject_CallObject(pFunc, NULL);
Py_Finalize(); system("pause");
}