C++嵌入Python最简例
2006-08-04 13:09
274 查看
最简单的内嵌Python例子,完全照搬手册上的例子:
#include <Python.h>
int
main(int argc, char *argv[])
{
Py_Initialize();
PyRun_SimpleString("from time import time,ctime/n"
"print 'Today is',ctime(time())/n");
Py_Finalize();
return 0;
}
注意:
* 需要指定include, lib目录
* 对于g++, 需手工加入python库: -lpython24
* 对于VC, 库会自动加入,但应绕过调试库:
// http://mail.python.org/pipermail/python-list/2002-February/089443.html #ifdef _DEBUG
#undef _DEBUG
#include <Python.h>
#define _DEBUG
#else
#include <Python.h>
#endif
#include <Python.h>
int
main(int argc, char *argv[])
{
Py_Initialize();
PyRun_SimpleString("from time import time,ctime/n"
"print 'Today is',ctime(time())/n");
Py_Finalize();
return 0;
}
注意:
* 需要指定include, lib目录
* 对于g++, 需手工加入python库: -lpython24
* 对于VC, 库会自动加入,但应绕过调试库:
// http://mail.python.org/pipermail/python-list/2002-February/089443.html #ifdef _DEBUG
#undef _DEBUG
#include <Python.h>
#define _DEBUG
#else
#include <Python.h>
#endif
相关文章推荐
- C++嵌入Python最简例
- C++嵌入python ,通过boost.python
- python嵌入到C++的一些理解
- C++中嵌入python程序——参数传递
- C/C++嵌入Python(Embedding Python in Another Application)
- C++ 嵌入 Python3 -==- 1
- Python嵌入C/C++ (Python核心编程)
- [ZT]C++ 扩展和嵌入 Python
- C/C++中嵌入Python
- Python嵌入C++(1)
- boost.python入门教程 ----python 嵌入c++
- 如何打包Python脚本使用的Python库[C++嵌入Python]
- Python 嵌入C++/C等
- python嵌入C++代码中
- C++嵌入python
- Python嵌入C++详解(1)--HelloWorld
- C++ 扩展和嵌入 Python
- 用c++和python写GUI程序(python嵌入方式)
- 用c++和python写GUI程序(python嵌入方式)
- C++中嵌入python脚本(结巴分词)