字典物件¶
-
PyTypeObject PyDict_Type¶
- 為 穩定 ABI 的一部分.
PyTypeObject實例代表一個 Python 字典型別。此與 Python 層中的dict為同一個物件。
-
int PyDict_CheckExact(PyObject *p)¶
- Thread safety: Atomic.
若 p 是一個字典物件但並不是一個字典子型別的實例,則回傳 true。此函式每次都會執行成功。
-
PyObject *PyDict_New()¶
- 回傳值:新的參照。 為 穩定 ABI 的一部分. Thread safety: Atomic.
回傳一個新的空字典,或在失敗時回傳
NULL。
-
PyObject *PyDictProxy_New(PyObject *mapping)¶
- 回傳值:新的參照。 為 穩定 ABI 的一部分.
Return a
types.MappingProxyTypeobject for a mapping which enforces read-only behavior. This is normally used to create a view to prevent modification of the dictionary for non-dynamic class types.
-
PyTypeObject PyDictProxy_Type¶
- 為 穩定 ABI 的一部分.
The type object for mapping proxy objects created by
PyDictProxy_New()and for the read-only__dict__attribute of many built-in types. APyDictProxy_Typeinstance provides a dynamic, read-only view of an underlying dictionary: changes to the underlying dictionary are reflected in the proxy, but the proxy itself does not support mutation operations. This corresponds totypes.MappingProxyTypein Python.
-
void PyDict_Clear(PyObject *p)¶
- 為 穩定 ABI 的一部分. Thread safety: Atomic.
清空現有字典中的所有鍵值對。
-
int PyDict_Contains(PyObject *p, PyObject *key)¶
- 為 穩定 ABI 的一部分. Thread safety: Safe for concurrent use on the same object.
Determine if dictionary p contains key. If an item in p matches key, return
1, otherwise return0. On error, return-1. This is equivalent to the Python expressionkey in p.
-
int PyDict_ContainsString(PyObject *p, const char *key)¶
- Thread safety: Atomic.
This is the same as
PyDict_Contains(), but key is specified as a const char* UTF-8 encoded bytes string, rather than a PyObject*.在 3.13 版被加入.
-
PyObject *PyDict_Copy(PyObject *p)¶
- 回傳值:新的參照。 為 穩定 ABI 的一部分. Thread safety: Atomic.
回傳一個新的字典,包含與 p 相同的鍵值對。
-
int PyDict_SetItem(PyObject *p, PyObject *key, PyObject *val)¶
- 為 穩定 ABI 的一部分. Thread safety: Safe for concurrent use on the same object.
Insert val into the dictionary p with a key of key. key must be hashable; if it isn't,
TypeErrorwill be raised. Return0on success or-1on failure. This function does not steal a reference to val.
-
int PyDict_SetItemString(PyObject *p, const char *key, PyObject *val)¶
- 為 穩定 ABI 的一部分. Thread safety: Atomic.
This is the same as
PyDict_SetItem(), but key is specified as a const char* UTF-8 encoded bytes string, rather than a PyObject*.
-
int PyDict_DelItem(PyObject *p, PyObject *key)¶
- 為 穩定 ABI 的一部分. Thread safety: Safe for concurrent use on the same object.
Remove the entry in dictionary p with key key. key must be hashable; if it isn't,
TypeErroris raised. If key is not in the dictionary,