一. 列表与切片
names = ["1zhangpeng","aguyu","litong","maziwei"]#列表
''''
print(names)
print(names[0],names[1])
print(names[1:2])#切片
print(names[-1])
print(names[-1:-3]) #错误
print(names[-3:]) #顾头不顾尾
print(names[0:3])
print(names[:3])
names.append("leijun") #往列表插入数据(末尾),追加数据
names.insert(1,"chengzhonghua")#任意位置
names[2] = "bilaoye" #修改
#delete
names.remove("bilaoye") #方法1
del names[1] #方法2 =names.pop(1)
names.pop() #默认删除最后一个位置,
print(names.index("zhangpeng")) #查询在列表中的位置
print(names[names.index("zhangpeng")]) #打印
print(names.count("zhangpeng"))# 查询在列表中出现的次数
'''
names.reverse() #反转
names.sort() #排序
names2 = [1,2,3,4]
names.extend(names2) #扩展
print(names)
print(names2)
del(names2)
print(names2)
copy与deepcopy 浅拷贝与深拷贝
names = ["1zhangpeng","aguyu",["dalao","xiaolao"],"lisan","xiaoming"]#列表
names2 = names.copy() #浅拷贝
names[2][1] = "DALAO"
print(names)
print(names2)
print(names[2][1])
names = ["1zhangpeng","aguyu",["dalao","xiaolao"],"lisan","xiaoming"]#列表
print(names[0:-1:2])#跳着切片
for i in names:
print(i) #挨个儿打印