c/c++调用python(2)

来源:互联网 发布:知乎回答问题有收入吗 编辑:程序博客网 时间:2024/06/11 07:41

前一篇文章已经详细叙述了c调用Python的基本用法
http://blog.csdn.net/wc781708249/article/details/60134515

这篇算是上一篇的补充篇


使用C/C++执行python脚本


python 2.x

PyRun_SimpleString("execfile('pytest.py')");

pythton 3.x

PyObject *obj = Py_BuildValue("s", "pytest.py");FILE *fp = _Py_fopen_obj(obj, "r+");if (fp == NULL)   return -1;PyRun_SimpleFile(fp, "pytest.py");

参考文献:
http://blog.csdn.net/chunleixiahe/article/details/50410208
http://www.360doc.com/content/13/0812/11/9934052_306564761.shtml
http://blog.csdn.net/taiyang1987912/article/details/44779719
http://blog.csdn.net/shenwansangz/article/details/44019433
http://blog.csdn.net/shenwansangz/article/details/50055107
https://docs.python.org/3.5/extending/index.html#extending-index
http://blog.csdn.net/chunleixiahe/article/details/50410553

0 0
原创粉丝点击