python 基础(三) list 的用法
'''
列表的用法
'''
names = ['A',['V','W'],'B','C','D']
print(names[0:-1:2])
print(names[::2])
#列表的循环
for i in names :
print(i)
#f复制(浅复制)
#names3 = names.copy()
#复制(深复制)
import copy
names3 = copy.deepcopy(names)
print(names)
print(names3)
names[0] = 'O'
names[1][0]= 'Z'
print(names)
print(names3)
#切片
print(names[1],names[3])
print(names[1:3])
print(names[-3:-1])
print(names[-3:])
print(names[:3])
#新增
names.append('E')
names.insert(1,'F')
#修改
names[1] = 'G'
#删除
#names.remove('A')
#del names[0]
#names.pop(0)
print(names)
#查找
print(names.index('C'))
print(names[names.index('C')])
#反转
names.reverse()
#排序(根据编码顺序排序)
#names.sort()
print(names)
names2= [1,2,3,4]
#合并
#names.extend(names2)
input(names)