There is no concept of array in Python. Array is a data structure. A collection is a data structure that contains a set of elements.
Summary of data structures in Python:
In Python there are only tuples and lists;
Once a tuple is created, it cannot be changed, for example: aa=tuple(1,2,3);
Tuples cannot append (append) elements or pop (pop) Elements, etc.;
Only the elements in the tuple can be indexed aa[0], and the tuples therein cannot be assigned aa[0]=8;
The advantage of using tuples is that operating on tuples is more efficient and suitable for storing a set of constants;
While many of the above are not possible, it is possible to use a list.
For arrays:
list: array
tuple: read-only array
dict: dictionary
set: Set (can be regarded as a set in a mathematical sense)
The above is the detailed content of Is an array a collection in python?. For more information, please follow other related articles on the PHP Chinese website!