用在函數傳參上,所以沒辦法用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