list
li = [111,222]
# The operation behind it is
li = list([111,222])
# Convert string to list type
x = "aasdasd"
li = list(x)
print(li) #['a', 'a', 's', 'd', 'a', 's', 'd']
# Translate the dictionary into English , It's a dictionary "key"
# working principle
li = []
x = "aasdasd"
for i in x:
li.append(i)
print(li)
l=['a','b','c']
# positive
print(l[1]) #b
# reverse
print(l[-1]) #c
# Change value , Change the case
l[2]='d'
print(l) #['a', 'b', 'd']
# If the index does not exist, an error is reported
l[8]='d'
print(l) # Report errors
li=['song','hai','xing','hhh','lihai']
# Look at the head and ignore the tail 、 step
print(li[0:3]) # ['song','hai','xing']
print(li[0:5:2]) # ['song','xing','lihai']
# All slices ( Shallow copy )
print(li[:len(li)])
print(li[0:])
print(li[:])
# Reverse the list
print(li[::-1]) # ['lihai', 'hhh', 'xing', 'hai', 'song']
ps : Depth copy https://www.cnblogs.com/songhaixing/p/14015669.html
li=['song','hai','xing','hhh','lihai']
print(len(l)) #5
li = [111,222,333,[344,33]]
print(111 in l) #True
print(099 in l) #False
l=["aaa",2222,"cccc"]
res=l.append("ddd")
l.append("eee")
print(l) # ['aaa', 2222, 'cccc', 'ddd', 'eee']
print(res) # None ( No return value )
l=["aaa",2222,"cccc"]
res=l.insert(1,"xxx")
print(l) #['aaa', 'xxx', 2222, 'cccc']
print(res) #None ( No return value )
msg=['song','hai','xing','hhh','lihai']
# Delete... By index
del msg[1]
del msg[1:5:2] #del Add slices (hai,hhh)
print(msg)
# Delete directly through the element , no return value
msg.remove('hai')
print(msg)
# Delete... By index , And you can get this value
msg.pop(1)
msg.pop() # Do not place index, delete end by default
print(msg)
# "pop" Unique functions of : There is a return value
print(msg.pop(1)) # You can pop up this value
print(msg.remove('hai')) # Just delete , It doesn't return this value
l=[111,222,333,444,555,666,777]
for i in l:
print(i)
l=[111,222,333,444,111,555,666,777]
print(l.count(111)) #2
l=[111,222,]
# character string
l.extend("hello")
print(l) #[111, 222, 'h', 'e', 'l', 'l', 'o']
# list
l.extend(["xxx","yyy"])
print(l) #[111, 222, 'h', 'e', 'l', 'l', 'o', 'xxx', 'yyy']
# If you add a dictionary, you add "key"
msg=['song','hai','xing','song','lihai']
msg.clear()
print(msg) # []
msg=['song','hai','xing','song','lihai']
l=msg.copy()
print(l) # ['song','hai','xing','song','lihai']
msg=['song','hai','xing','hhh','lihai']
print(msg.count('hai')) # 1
msg=['song','hai','xing','song','lihai']
print(msg.index('song',2,4)) # 3 ( I can't find a mistake )
l=[5,7,9,3,1,4]
l.sort() # Sort
print(l)
# Parameters "reverse" trans
l.sort(reverse=True) # Reverse sorting
print(l)
li = [1, 'egon', 'alex', 'lxx']
li.reverse()
print(li) # ['lxx', 'alex', 'egon', 1]
# according to ascll Compare the decimal system corresponding to the code table
l1='hello'
l2='k'
print(l1 < l2) #abcd.... From small to large
l1=[3,'a','g','j',]
l2=[1,'c','g',]
print(l1 > l2) # One by one , Otherwise an error
print('Z'>'a') # Upper case is less than lower case A-Z,a-z
print('a'>'G') # Larger than any capital letter
l=[]
# Queue entry
l.append("first")
l.append("second")
l.append("third")
print(l) #['first', 'second', 'third']
# Out of the team
print(l.pop(0)) #first
print(l.pop(0)) #second
print(l.pop(0)) #third
l=[]
# Push
l.append("first")
l.append("second")
l.append("third")
print(l) #['first', 'second', 'third']
# Out of the stack
print(l.pop()) #third
print(l.pop()) #second
print(l.pop()) #first
( Last in, first out )
l=[]
# Push
l.append("first")
l.append("second")
l.append("third")
print(l) #['first', 'second', 'third']
# Out of the stack
print(l.pop()) #third
print(l.pop()) #second
print(l.pop()) #first