The magic of lists

1. All four black magics in the string are available

2.in , not in

3. Modify

4. Delete

li = [4,5,74864,6465 ,]
 del li [2 ]
 print (li)

5. Operation (always looking for the most accurate number inside)

li = [4,5,74864, [55,4546, [54,544,4]] 6465 ,]
 del li [3] [2 ] [0] [0]
 print (li)

6. String to list (numbers cannot be converted to lists, because numbers cannot be for loops)

r = "hahahha"
v = list(r)
print(v)

7. To convert a list to a string, you need to write your own for loop. In the case of both numbers and strings

li = [45,45,"df","gd"]
s = " "
for i in li:
    s = s + str(i)
print(s)

8. If there are only strings in it

li = ["45","df","gd"]
v
= " ".join(li) print(v)

li = ["45","df","gd"]
v = list(li)
print(v)

Guess you like

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