列表的增删改查,排序
'''#代码开始 list_1=['gong','juanxu','jing'] print(list_1[2]) list_1[2]="xia" #添加一个元素 print(list_1) print("Wellcome to there ",list_1[0]) print("Wellcome to there ",list_1[1]) print("Wellcome to there ",list_1[2]) for i in ("chen","Ronin","Jimi"): 遍历插入元素 list_1.append(i) print(list_1) list_1.insert(0,"chun") #在选择的位置插入元素 list_1.insert(3,"chun") list_1.append("qing") print(list_1) for i in list_1: print("Wellcome to there ",i) num_bg=0 while True: num_bg +=1 if num_bg == 8: break else: guest=list_1.pop() print("I'am Sorry ",guest.title()) print(list_1) print("Hello ",list_1[0],list_1[1]) del list_1[0,1] print(list_1) '''代码结束 list_2=["chongqing","hubei","guagxi","beihai"] ''' print(sorted(list_2,reverse=True)) print(list_2) ''' list_2.reverse()#反转列表 print(list_2) list_2.reverse() print(list_2) list_2.sort()#排序 print(list_2) list_2.sort() print(list_2)