python list操作
1 # 1、+ 2 list1 = [1, 2, 3, 4] 3 list2 = [5, 6, 7, 8] 4 list3 = [1, 2, 3, 4] 5 6 print(list1 + list2) 7 print(list1) 8 print(list2) 9 10 11 # 2、contains 12 print(1 in list1) 13 14 15 # 3、eq 16 print(list1 == list3) 17 18 19 # 4、iter 20 print(iter(list1)) 21 22 23 # 5、len 24 print(len(list1)) 25 26 27 # 6、not eq 28 print(list1 != list2) 29 30 31 # 7、append 32 list3.append(5) 33 print(list3) 34 35 36 # 8、clear 37 list3.clear() 38 print(list3) 39 40 41 # 9、copy 42 list4 = list1.copy() 43 print(list4) 44 45 46 # 10、count 47 print(list1.count(1)) 48 49 50 # 11、extend 51 list3.extend([5, 6, 7, 8]) 52 print(list3) 53 54 55 # 12、index 56 print(list1[2]) 57 58 59 # 13、insert 60 list3.insert(0, 4) 61 print(list3) 62 63 64 # 14、pop 65 print(list3.pop()) 66 print(list3.pop(0)) 67 print(list3) 68 69 70 # 15、remove 71 list3.remove(6) 72 print(list3) 73 74 75 # 16、reserve 76 list1.reverse() 77 print(list1) 78 79 80 # 17、sort 81 list1.sort() 82 print(list1)