c++调用python的入门例子
2009-03-19 18:09
996 查看
#mytest.py you = 'world!' print 'aaaaaaaa' def hello(): print 'hello,world' hello()
c++调用
#include <Python.h> int main() { Py_Initialize(); PyObject *pModule = NULL; PyObject *pFunc = NULL; PyRun_SimpleString("import sys"); PyRun_SimpleString("sys.path.append('./')"); pModule = PyImport_ImportModule("mytest"); pFunc = PyObject_GetAttrString(pModule, "hello"); PyEval_CallObject(pFunc, NULL); Py_Finalize(); return 0; }
相关文章推荐
- 用一个简单示例演示在python中调用C及C++
- 从C++到Python入门
- C++调用Python
- windows下,python调用dll例子,展示如何传递字节码流参数到dll接口
- Python In Action:一、入门小例子
- Boost.Python实现C++与Python互调用
- python下面通过ctypes模块调用c++库的方法
- python下面通过ctypes模块调用c++库的方法
- python下面通过ctypes模块调用c++库的方法
- C++动态调用dll库(例子)
- Java JNI入门篇——C++中调用Java方法
- C++调用python,直接调用模块内函数,调用类内函数
- RPC框架Thrift例子-PHP调用C++后端程序
- python与c++交互学习入门之5
- python调用dll例子
- Windows下QT中用C++调用Python之一 - 基础调用
- Windows下QT中用C++调用Python之二 - 编译BUG处理
- Python入门的36个例子——02 Help! —— 如何获取帮助
- Python入门的36个例子——08 If —— 分叉语句
- Python入门的36个例子之16: 关键参数 —— 嘿!请把这个纸条给小强