python - How to convert char* object to PyObject* object
漂亮男人
漂亮男人 2017-06-10 09:48:40
0
1
1073

is used for function parameter transfer, so PyObject_GetAttrString cannot be used

漂亮男人
漂亮男人

reply all(1)
滿天的星座

PyByteArray_FromStringAndSize or Py_BuildValue first converts char * into bytes
Then PyTuple_SetItem converts bytes into tuple

        PyObject * bytesObject = PyByteArray_FromStringAndSize(message, len);
        PyObject * buildObject = Py_BuildValue("y#", message,len);
        PyObject * argsObject = PyTuple_New(1);
        PyTuple_SetItem(argsObject, 0, bytesObject);
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template