C/C++编程调用Python脚本集锦

1.C++调用Python脚本中的函数这是基于vs的。如果用于纯C++,如Dev C++(这个已经测试通过),  BC++B(这个还没测试)。注释掉

//#include "stdafx.h" 
将语句:int _tmain(int argc, _TCHAR* argv[])
修改为:int main()。头部代码如下:
//#include "stdafx.h" 
#include <stdlib.h>
#include <iostream> 
#include <Python.h>
using namespace std;

//int main(int argc, _TCHAR* argv[])
int main(void)

{

}

  Python安装为最新版的32位的V3.9.5版。


添加:包含文件的路径,如:D:\Python\Pyth3.9.5\include
添加:链接参数,如:
-ID:\Python\Pyth3.9.5\include
-LD:\Python\Pyth3.9.5\libs
-lpython39
2.Python代码的编译
3.Dev C++中C语言程序调用Python


posted @ 2021-05-31 23:46  曦海客·一策书·萬江波  阅读(360)  评论(0编辑  收藏  举报