#include "stdafx.h"
#include "Python.h"
#include <iostream>
#pragma comment( lib, "python22.lib" )
int _tmain(int argc, _TCHAR* argv[])
...{
Py_Initialize();
PyObject * module;
PyObject * dict;
PyObject * obj;
long lval;
PyRun_SimpleString("obj = (3 * 5)+8");
module = PyImport_AddModule("__main__");
dict = PyModule_GetDict(module);
obj = PyMapping_GetItemString(dict, "obj");
if (obj != NULL)
...{
lval = PyInt_AsLong(obj);
printf("obj: %d ", lval);
}
else
...{
printf("Object not found ");
}
return 0;
}
#include "Python.h"
#include <iostream>
#pragma comment( lib, "python22.lib" )
int _tmain(int argc, _TCHAR* argv[])
...{
Py_Initialize();
PyObject * module;
PyObject * dict;
PyObject * obj;
long lval;
PyRun_SimpleString("obj = (3 * 5)+8");
module = PyImport_AddModule("__main__");
dict = PyModule_GetDict(module);
obj = PyMapping_GetItemString(dict, "obj");
if (obj != NULL)
...{
lval = PyInt_AsLong(obj);
printf("obj: %d ", lval);
}
else
...{
printf("Object not found ");
}
return 0;
}