c中调用python解释器
生活随笔
收集整理的這篇文章主要介紹了
c中调用python解释器
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
c中調用python解釋器
#include?<iostream>
#include?<string>
#include?"Python.h"
int?main()
{
????std::cout?<<?"Welcome?to?SIMPLEPYTHON!!"?<<?std::endl;
????std::cout?<<?"Chapter?17,?Demo?01?-?MUD?Game?Programming"?<<?std::endl;
????Py_Initialize();????????????????//?initialize?python
????std::string?str;
????std::getline(?std::cin,?str?);
????while(?str?!=?"end"?)
????{
????????PyRun_SimpleString(?const_cast<char*>(?str.c_str()?)?);
????????std::getline(?std::cin,?str?);
????}
????Py_Finalize();??????????????????//?shut?down?python
????return?0;
}
posted on 2009-11-10 20:53 邁克老狼 閱讀(...) 評論(...) ?編輯 收藏
?
非常的簡單,
Code#include?<iostream>
#include?<string>
#include?"Python.h"
int?main()
{
????std::cout?<<?"Welcome?to?SIMPLEPYTHON!!"?<<?std::endl;
????std::cout?<<?"Chapter?17,?Demo?01?-?MUD?Game?Programming"?<<?std::endl;
????Py_Initialize();????????????????//?initialize?python
????std::string?str;
????std::getline(?std::cin,?str?);
????while(?str?!=?"end"?)
????{
????????PyRun_SimpleString(?const_cast<char*>(?str.c_str()?)?);
????????std::getline(?std::cin,?str?);
????}
????Py_Finalize();??????????????????//?shut?down?python
????return?0;
}
posted on 2009-11-10 20:53 邁克老狼 閱讀(...) 評論(...) ?編輯 收藏
轉載于:https://www.cnblogs.com/mikewolf2009/articles/1600466.html
總結
以上是生活随笔為你收集整理的c中调用python解释器的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Windows不同版本的解释
- 下一篇: Python类继承简单实现