Adding python script to c++ project

我的未来我决定 提交于 2019-12-10 19:35:56

问题


How would I go about adding a script written in python to a c++ project? Thanks

Edit: Basically all the script does is email some data. I would like to pass the data and maybe the email address to a function written in python. Hope that clears things up..


回答1:


You could look at Boost.Python which is a "a C++ library which enables seamless interoperability between C++ and the Python programming language."

You have to be more specific, though.




回答2:


You may be interested in Boost.Python: Embedding the Interpreter, or Python/C API: Embedding the Python Interpreter. You can either use the Python C APIs directly or use the Boost.Python library as you so choose. You might also be interested in reading Embedding Python in Your C Programs which walks you through it.




回答3:


The most primitve solution would be to use the system command to call you script, but that does limit your control over it to setting environment variables and passing parameters.

system("myscript.py param1 param2") 


来源:https://stackoverflow.com/questions/2627173/adding-python-script-to-c-project

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!