1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
|
Py_Initialize();
PyObject *pName, *pModule, *pFunc;
PyObject *pArgs, *pValue;
String maStringCPP = "Je suis une string super cool !"
pName = PyString_FromString("module");
pModule = PyImport_Import(pName);
pFunc = PyObject_GetAttrString(pModule, "modifier");
pArgs = PyTuple_New(1);
pValue = PyString_FromString(maStringCPP);
PyTuple_SetItem(pArgs, 0, pValue);
// Ici on appel la méthode modifier en donnant en paramète la string
PyObject_CallObject(pFunc, pArgs);
Py_Finalize(); |
Partager