Article From:https://www.cnblogs.com/MrYangjlPython/p/9971442.html

1.list

Ordered, elements can be modified

li=[1,2,2,”am”,”123″]

The elements in the list can be numbers, strings, lists, and so on.

Support slicing, slicing results for list Li [3], Li [3:-1]

Modify Li [2] = 3 Li [1:3]= [120,90]

Delete del Li [1] del [3:5], before and after the package

inOperations to determine whether an element is in a collection

list(str)Transfer a string to a list. Only data types that can perform for loops can be converted to a list

str(li)  Converting lists to strings

When there are both strings and numbers in the list, only for loops can be used for stitching. If there are only strings in the list, then join method will do.

2.listMethod in

def append(self, *args, **kwargs)    listAdditional character, no return value

def clear(self, *args, **kwargs):Empty string

def copy(self, *args, **kwargs)   shallow copy

def count(self, *args, **kwargs)  Calculate the number of elements

def extend(self, *args, **kwargs) Batch Addition Required Parameters

def index(self, *args, **kwargs) Find the index location of a value, left first

def insert(self, *args, **kwargs)  Insert a value at the specified index location

def pop(self, *args, **kwargs)   Gets and deletes the value of an index location by default to the last

remove  Delete a value

reverse Current list flip

sort Sort, default from small to large, reverse = True from large to small

Note that strings cannot be modified by slicing

3.Tuple tuple

Special list, elements can not be modified, can not be added or deleted, when writing meta-ancestors, add a comma at the end

tu=(111,22,33,44,)

Can be indexed and sliced

You can do for loops, which are iterative objects.

Strings, lists, tuples can be converted to each other

You can convert a join to a string

Orderly

Method, count gets the number of occurrences of the specified element in the tuple.

indexGet the location of a value