列表的增删查改
01 查
列表的查询与字符串的切边几乎一样,切片去查或者循环去查
如:
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
l1 = ['das', 'dfsdf',[1,23,],'asda'] li = l1[0] print(li) l2 = l1[0:3] print(l2)
![](https://img2018.cnblogs.com/blog/1743151/201907/1743151-20190719220900656-1433603540.png)
02 增
1 append 增加到最后
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
l1 = ['das', 'dfsdf',[1,23,],'asda'] l1.append('sfdg') l1.append(324314) print(l1)
![](https://img2018.cnblogs.com/blog/1743151/201907/1743151-20190719221225339-1058503419.png)
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
l1 = ['das', 'dfsdf',[1,23,],'asda'] while 1: username = input('>>>') if username.upper().strip() == 'Q': break else: l1.append(username) print(l1)
02 insert 选择插入
03 extend 迭代添加
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
l1 = ['das', 'dfsdf',[1,23,],'asda'] l1.extend("udhsfi") l1.extend([1,2,3,4,5,6]) print(l1)
![](https://img2018.cnblogs.com/blog/1743151/201907/1743151-20190719223405774-218445906.png)