list method

list1 + list2 is to combine the elements of the two lists into one

list1.count( ) Check how many certain elements are in the list

list1.index(value,start,stop) View the index of an element in the list

list1.sort(reverse= ) The default reverse is False, you can change it to True to sort from big to small.

list2 = list1 ; list3 = list1[ : ] The difference is that the latter directly copies a new list, while the former is a new label that points to list 1 in memory, if

If list 1 changes, then list 2 will also change, and the latter is generally used to copy lists.

list4 =list1.copy( ) copies a list

list1.clear turns the list into an empty list

list1.reverse( ) reverses the elements in the list

list4 = list1 * 3 

列表推导式:    list1 = [(x,y) for x in range(10) for y in range(10) if x %2 == 0 if y %2 !=0]


Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325941718&siteId=291194637