How to get a char* from a PyObject which points to a string
问题 How can I get a char* from a PyObject which points to a string. For example, this is the python script, Test.Connect("272.22.20.65", 1234) and this is the C++ code, static PyObject* Connect(PyObject *self, PyObject *args) { PyObject* pIP; PyObject* pPort; if (!PyArg_UnpackTuple(args, "Connect", 2, 2, &pIP, &pPort)) { return NULL; } const char* zIP = GetAsString(pIP); long iPort = PyLong_AsLong(pPort); I want to get that IP address as a char* (GetAsString is a dummy function :D ). Please note