In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
Today, I will talk to you about Python or C API numbers in the operation of the processing steps is what kind of, may not be a lot of people understand, in order to let you know more, Xiaobian summarized the following content for you, I hope you can according to this article to gain something.
The Python/C API provides the Py_BuildValue() function to convert numbers and strings into the corresponding data types in Python. The prototype of its correlation function is shown below.
PyObject* Py_BuildValue( const char *format, ...)
The parameters have the following meanings.
format: Format a string,
The remaining arguments in the Py_BuildValue() function are integers, floating-point types, or strings in C to be converted. Pointer whose return value is of type PyObject. In C, all Python types are declared as PyObject.
Read and write files in Python implementation script details
Python MD5 file generation code actually related to the content of the introduction
A detailed introduction to Python features
Python history and its place in programming languages
Python design concepts are also new in computer language applications
Python/C API List Operations
PyList_New() function is provided in Python/C API to create a new Python list. The PyList_New() function returns the list created. The prototype function is shown below.
PyObject* PyList_New( Py_ssize_t len)
The parameters have the following meanings.
len: Length of the list created.
After the list is created, you can add items to the list using the PyList_SetItem() function. The prototype function is shown below.
int PyList_SetItem( PyObject *list, Py_ssize_t index, PyObject *item)
The parameters have the following meanings.
list: List of items to add.
index: The index of the location of the added item.
item: Value of the item being added.
You can also use the PyList_GetItem() function in the Python/C API to get the value of an item in a list. The PyList_GetItem() function returns the value of the item. The prototype function is shown below.
PyObject* PyList_GetItem( PyObject *list, Py_ssize_t index)
The parameters have the following meanings.
list: List of actions to be taken.
index: positional index of the item.
Functions corresponding to list operations in Python are provided in the Python/C API. For example, the append method for a list corresponds to the PyList_Append() function. The sort method for lists corresponds to the PyList_Sort() function. The reverse method of a list corresponds to the PyList_Reverse() function. The function prototypes are shown below.
int PyList_Append( PyObject *list, PyObject *item)
int PyList_Sort( PyObject *list)
int PyList_Reverse( PyObject *list)
For the PyList_Append() function, its parameters mean the following:
list: List of actions to be taken.
Item: The item to participate in.
For PyList_Sort() and PyList_Reverse() functions, the arguments have the same meaning.
list: List of actions to be taken.
After reading the above, do you have any further understanding of how Python or C API numbers are processed? If you still want to know more knowledge or related content, please pay attention to the industry information channel, thank you for your support.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.