Chinaunix首页 | 论坛 | 博客
  • 博客访问: 475344
  • 博文数量: 133
  • 博客积分: 1235
  • 博客等级: 少尉
  • 技术积分: 1201
  • 用 户 组: 普通用户
  • 注册时间: 2010-09-08 19:59
文章分类

全部博文(133)

文章存档

2023年(12)

2022年(3)

2018年(2)

2017年(4)

2016年(4)

2015年(42)

2014年(1)

2013年(12)

2012年(16)

2011年(36)

2010年(1)

分类: 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");
 }

阅读(2205) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~