【发布时间】:2014-05-06 08:04:39
【问题描述】:
我有一个问题,如何清除由PyList_Append() 组成的列表?
有没有详细介绍 Python/C 扩展 API 函数的文档?
【问题讨论】:
-
谢谢,还有一个问题。 PyObject *newlist = PyList_New(0); PyObject *subList = PyList_New(0); PyList_Append(subList, PyString_FromString("first")); PyList_Append(subList, PyString_FromString("second")); PyList_Append(subList, PyString_FromString("third")); PyList_SetSlice(subList, 0, PyList_Size(subList), NULL); PyList_Append(subList, PyString_FromFormat("abcdef")); PyList_Append(newlist, subList);现在我得到 [['abcdef'],['abcdef']]。初始字符串“first”和“second”被覆盖。如何解决?抱歉,我不知道如何编辑格式。也许我需要一个教程。
标签: python python-c-api