This article mainly with you to share Python common list method, mainly in the form of code and we explain, hope to help everyone.
Append (...) add an element at the end of the list
| L.append (object), None--Append object to end
Count (...) checks if the content exists in the list element
| L.count (value), integer--return number of occurrences of value
Extend (...) merge list
| L.extend (iterable), None--extend list by appending elements from the iterable
Insert (...) inserts an element before an element
| L.insert (Index, object)--Insert object before index
Pop (...) delete an element The default is the last Pop (0) is to delete the first element
| L.pop ([index]), item-Remove and return item at index (default last).
| Raises indexerror If list is an empty or index is out of range.
Sort (...) ordering requires the same element type, otherwise an error will occur!
| L.sort (Key=none, Reverse=false), None--stable sort *in place*
Reverse (...) reverse order
| L.reverse ()--Reverse *in place*
| Remove (...) to delete an element of a value
| L.remove (value), None--Remove first occurrence of value.
| Raises valueerror if the value is not present.