1000字范文,内容丰富有趣,学习的好帮手!
1000字范文 > python c参数 CPython – 读取C函数内的Python字典(键/值)作为参数传递

python c参数 CPython – 读取C函数内的Python字典(键/值)作为参数传递

时间:2018-07-15 22:45:44

相关推荐

python c参数 CPython – 读取C函数内的Python字典(键/值)作为参数传递

你应该通过链接,

/2/c-api/dict.html

摘录如下,

PyObject* PyDict_GetItem(PyObject *p, PyObject *key)

Return value: Borrowed reference.

Return the object from dictionary p which has a key key. Return NULL if the key key is not present, but without setting an exception.

PyObject* PyDict_GetItemString(PyObject *p, const char *key)

Return value: Borrowed reference.

This is the same as PyDict_GetItem(), but key is specified as a char*, rather than a PyObject*.

PyObject* PyDict_Items(PyObject *p)

Return value: New reference.

Return a PyListObject containing all the items from the dictionary, as in the dictionary method dict.items().

PyObject* PyDict_Keys(PyObject *p)

Return value: New reference.

Return a PyListObject containing all the keys from the dictionary, as in the dictionary method dict.keys().

PyObject* PyDict_Values(PyObject *p)

Return value: New reference.

Return a PyListObject containing all the values from the dictionary p, as in the dictionary method dict.values().

留意借来的参考/新参考.编写Python扩展时有点棘手.

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。