Directly run the Code:
// #====================================================== ==================================/// # Author: ago // #19:26:57 // #============================================ ========================================#include "python_lib/Python. h "# include <windows. h> # pragma comment (lib, "python27_d.lib") int main (int argc, char * argv []) {Py_Initialize (); // PyRun_SimpleString ("import sys "); // PyRun_SimpleString ("sys. path. append ('. /') "); PyObject * pName = PyString _ FromString ("main"); // python file name: PyObject * pModule = PyImport_Import (pName); if (! PModule) {MessageBox (NULL, ("main. py "), (" prompt "), MB_ OK); return 1;} PyObject * pDict = PyModule_GetDict (pModule); PyObject * pFunc = PyDict_GetItemString (pDict," test "); // number of letters in the python file: testPyObject_CallObject (pFunc, NULL); Py_Finalize (); system ("pause ");}