Python3.6 list functions & methods

function:

January 1 (list)

    number of list elements

2、max(list)

    Returns the maximum value of a list element

3、min(list)

    Returns the minimum value of a list element

4、list(seq)

    Convert tuple to list

5、enumerate()

    print the subscript corresponding to the element

    Example:

      

 

method:

1、list.append(self, p_object)

    Add a new object p_object at the end of the list

2、list.clear(self)

    Empty the list, the method has no return value

3、list.copy(self)

    Copy the list, return the new list after copying, the original value and the newly copied variable do not affect each other

4、list.count(self, value)

    Count the number of times an element value appears in a list

5、list.extend(self, iterable)

    Append multiple values ​​from another sequence at once at the end of a list (extend the original list with the new list)

6、list.index(self, value, start=None, stop=None)

    Find the index position of the first occurrence of a value from a list

7、list.insert(self, index, p_object)

    Insert the object p_object into the specified index position index of the list, if the specified subscript does not exist, then add it at the end

8、list.pop(self, index=None)

    Removes an element specified in the list (the last element by default) and returns the value of that element

9、list.remove(self, value)

    removes the first occurrence of a value in a list

10、list.reverse(self)

    reverse the list

11、list.sort(self, key=None, reverse=False)

    对原列表排序,默认升序,reverse=True,降序排列

    注:list 中有字符串,数字时不能排序,排序针对同类型

 

Guess you like

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