用在函数传参上,所以没法用PyObject_GetAttrString
PyByteArray_FromStringAndSize 或者Py_BuildValue先把char *转成bytes然后PyTuple_SetItem把bytes 转成tuple
PyObject * bytesObject = PyByteArray_FromStringAndSize(message, len); PyObject * buildObject = Py_BuildValue("y#", message,len); PyObject * argsObject = PyTuple_New(1); PyTuple_SetItem(argsObject, 0, bytesObject);
PyByteArray_FromStringAndSize 或者Py_BuildValue先把char *转成bytes
然后PyTuple_SetItem把bytes 转成tuple