我试图将3d整数列表从Python3传递给C,然后使用Python C API将2d字符串数组从C返回给Python。我有支持功能的工作,以便procStrings是可调用的。但是,我很难弄清楚如何将数组传入/传出以及如何从数组中获取项目。
================================================ ==========
static PyObject* my_module_procStrings(PyObject* self, PyObject* args)
{
int rows, cols;
int ii, jj;
PyObject* listObj;
// Get the 2d list and parameters from Python call
if( !PyArg_ParseTuples(args, "O!ii", &PyList_Type, &listObj, &rows, &cols ))
{
return NULL;
}
// Convert the input to a 3d array in C here?
// Process the input array / create the output array
for( ii = 0; ii < rows; ii++ )
{
for( jj = 0; jj < cols; jj++ )
{
// Code for setting new array entry based on entry from input array goes here
}
}
// How is the new 2d string array returned ?
}