01 查
列表的查询与字符串的切边几乎一样,切片去查或者循环去查
如:
l1 = [‘das‘, ‘dfsdf‘,[1,23,],‘asda‘] li = l1[0] print(li) l2 = l1[0:3] print(l2)
02 增
1 append 增加到最后
l1 = [‘das‘, ‘dfsdf‘,[1,23,],‘asda‘] l1.append(‘sfdg‘) l1.append(324314) print(l1)
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 迭代添加
l1 = [‘das‘, ‘dfsdf‘,[1,23,],‘asda‘] l1.extend("udhsfi") l1.extend([1,2,3,4,5,6]) print(l1)
原文地址:https://www.cnblogs.com/zly9527/p/11216070.html
时间: 2024-10-08 09:36:46