https://zhuanlan.zhihu.com/p/477695318
arr = ["Porsche", "Volvo", "BMW"]
x=len(arr)
arr[0]='car'
arr.append('auto') #添加元素
arr.remove('auto') #删除元素
arr.pop(1) #删除数组的第二个元素
# 数据源
names = ['a', 'b', 'c', 'd', 'e', 'f']
list[2]
倒着取
list[-2]
# 截取
names[0:3] # ['a', 'b', 'c']
names[3:10] # ['d', 'e', 'f']
# 截取:从3到指定结尾
names[3:] # ['d', 'e', 'f']
names[:3] # ['a', 'b', 'c']
# 倒着切
names[-2: -1] # ['e']
names[-2:] # ['e', 'f']
# 跳着切,步长
names[0: 5: 2] # ['a', 'c', 'e']
names[0::2] # ['a', 'c', 'e']
names[::2] # ['a', 'c', 'e']
arr.clear() #清空
arr.sort() #排序
arr.count() #元素数量
arr.insert(i,val) #插入元素
arr.copy() #返回副本
arr.reverse() #反序
print(len(arr))
#extend方法
c1 = ["Red","Green","Blue"]
c2 = ["Orange","Yellow","Indigo"]
c1.extend(c2)
#直接相加
c3 = c1 + c2
a = [[1,3],[2,4],[3,5]]
a = array(a)
a.flatten()
array([1, 3, 2, 4, 3, 5])
list[1:]