names = ["a","b","c","d","e","e","a"] #列表names2 = [1,2,3,4,5]#print(names[0:3])#切片#print(names[-2:])#切片#print(names[-2:-1])#切片‘‘‘------ -1 为最后一个位置 ------‘‘‘#print(names.count("a")) #求和names.append("LiSi") #插入最后位置names.insert(1,"f")#插入固定位置names[3] = "ZhangSan"#替换#names.remove("a") #删除#names.pop() #默认删除最后一个#names.pop(1) #按照下标删除ZS = names.index("ZhangSan")#c查找具体位置print(ZS)#print( names[names.index("ZhangSan")] )#根据下标取出名称 (会有用的记住哦)#names.clear()#清空内容#names.reverse()#反转#names.sort()#排序#names.extend(names2)#合并#del names2 # 删除name2print(names,names2)‘‘‘---------------------转发请注明地址-------------------------‘‘‘‘‘‘-------------------http://www.cnblogs.com/guanyf/-----------------‘‘‘
时间: 2025-01-03 15:58:22