我正在调试Python源代码(CPython 3.4)。我收到一个PyObject *。我想printf
吧。如何在Python3中获取PyObject的字符串表示形式?
例如(从3.4的Python源代码对象/ floatobject.c):
PyObject *o_ndigits = NULL;
Py_ssize_t ndigits;
x = PyFloat_AsDouble(v);
if (!PyArg_ParseTuple(args, "|O", &o_ndigits))
return NULL;
我怎样printf
o_ndigits?它与这个问题几乎相同:Python: get string representation of PyObject?,但是对于Python3。用原来的解决方案,我得到了"undefined reference to PyString_AsString"
错误。