If you provide the PyTuple_New () function in Python/c api, use it to create Python tuples. In this case, the PyTuple_New () function is used to return the created tuples. The prototype of functions related to Python/c apis is as follows.
PyObject * PyTuple_New (Py_ssize_t len)
The parameter meanings are as follows.
Len: the length of the created tuples.
After the tuples are created, you can use the PyTuple_SetItem () function to add items to the tuples. The function prototype is as follows.
- Introduction to the actual content of the Python MD5 file generation code
- A detailed introduction to Python features
- Python history and positioning of Python in programming languages
- The Python design concept is also a new development of computer language applications
- Actual steps for processing Python/c api numbers
Int PyTuple_SetItem (PyObject * p, Py_ssize_t pos, PyObject * o)
The parameter meanings are as follows.
P: The operation tuples.
Pos: The Position Index of the added item.
O: the added item value.
You can use the PyTuple_GetItem () function in Python/c api to obtain the value of an item in the tuples. The value of the return item of the PyTuple_GetItem () function. The function prototype is as follows.
PyObject * PyTuple_GetItem (PyObject * p, Py_ssize_t pos)
The parameter meanings are as follows.
P: The tuples to be operated.
Pos: The Position Index of the item.
After the tuples are created, you can use the _ PyTuple_Resize () function to re-adjust the size of the tuples. The function prototype is as follows.
Int _ PyTuple_Resize (PyObject ** p, Py_ssize_t newsize)
The parameter meanings are as follows.
P: pointer to the tuples to be operated.
Newsize: the size of the new element group.