There are mentioned below:
List; Ganso
The definition list
list (list) python is the most frequently used data types, called arrays in other languages
Specialized store a bunch of information
List [] is defined with a comma-separated data between
The index list is zero-based
The index is the data position number in the list, the index is also known as subscript
! ! ! ! Note that the value from the list if the index exceeds the scope of the program will be given
name_list = ["zhangsan", "lisi", "wangwu"]
A list of commonly used operating ah
Create a list in a casual as a file: name_list = []
Press the Tab will prompt to use list
In [1]: name_list.
name_list.append name_list.count name_list.insert name_list.reverse
name_list.clear name_list.extend name_list.pop name_list.sort
name_list.copy name_list.index name_list.remove
Furthermore, it is to loop through
It is traversed from start to finish in order to obtain data from the list
In the body of the loop for each element, the same operation
In python in order to improve the efficiency of traversing the list, iteration specializes traversal
We can use a for loop to achieve this Code
# For use in the inner loop variable list for name in name_ List: internal loop operation for the list elements Print (name)
Application of scene
Although the list of python may store different types of data
But in the development, application scenarios are more
List stored want the same type of data
By iterate through internal recirculation, for each element in the list, execute the same code
Originator
Defined Ganso
Tuole (ancestral) with a list of similar, except that the element can not be modified ancestral
Tuples a sequence of a plurality of elements
Ganso in python development, there is a specific application scenarios
String for storing information, using data between partition
Tuples with () is defined
Ganso index starting from 0
Is the index position number in the data element of ancestral
info_tuple=(“zhangsan”,18,1.75)
Create an empty Ganso
info_tuple=()
Ganso contains only one element is the need to add a comma after the element
info_tuple=(50,)
For a list and Ganso on here, we need a good exercise, and examples