Python data structure
one . list :

Python The list in is variable , be careful : List is [] square brackets , This is the most important feature that distinguishes it from strings and tuples , In short : The list can be modified , Strings and tuples cannot be modified . Let's demonstrate the list
list :
result : Successfully added Zhangshaohan to the list at the end
Let's take a look .extend Usage of
example :
result :extend Take Zhangshaohan apart and add one by one
insert Add for specified location , This function is very user-friendly , It's also very simple , Let's try it out
example :

result :instert Zhangshaohan was successfully added to the position I requested in the list
remove Delete element , stay () Enter the element you want to delete in , The usage is also very simple , Let's try it out , I want to delete Wang Xinling here
example :

example :remove Successfully deleted wangxinling , To delete that element, just enter the element to be deleted
pop It is also a deletion , and remove The difference is ,pop What is deleted is the specified position of the element , You can delete it by entering the location , Let's try it out
example :
result : We successfully deleted Jay Chou according to the specified location
clear A very simple command , clear list , Delete everything from the list
example :

result : It's easy , input clear() Clear delete list directly
index Simply put, find , If there is no compiler, an error will be reported , Let's try it out
example :

result : The compiler will report an error if there is no content found in the element
count Find the number of in the list , Now let's find out p How many in the list
example :

result : Found p Appears in the list 2 second
sort() Sort list , So we don't have to sort by ourselves , The compiler will automatically sort for us
example :

result : before a In the list 1 position , Implemented sort after , result a In the list 0 position , Sorting succeeded
We found out ,sort Can be arranged in positive order in the list , If I just don't want to be in positive order in the list , I just
Want to arrange it upside down , No problem , It's simple , Just execute .reverse Can , Let's try it out
example :
result :.reverse Successfully sorted the list in reverse order
Today's focus :append Add element
extend Take apart and add one by one
remove Delete element
clear clear list , Delete everything from the list
count Find the number of in the list
sort() Sort list

Technology