当前位置: 首页 > 后端技术 > Python

图解python - 列表

时间:2023-03-25 23:19:23 Python

ex('淘宝'))aList.insert(3,'DiDi')print("aList在索引3处插入元素后:",aList)print("从aList弹出的元素:",aList.pop())aList.remove('ShowMeAI')print("AList使用remove删除第一个匹配的ShowMeAI:",aList)aList.reverse()print("aList使用reverse进行倒序的结果:",aList)aList.sort()print("AListissortedbysort:",aList)结果aList:['Baidu','ShowMeAI','google']aListappend+计算后:['Baidu','ShowMeAI','google','ByteDance','ShowMeAI']统计ShowMeAI的个数:扩展后2个aList:['Baidu','ShowMeAI','google','ByteDance','ShowMeAI','淘宝','腾讯']使用索引查找淘宝的索引位置:5aList在索引3处插入元素后:['Baidu','ShowMeAI','google','DiDi','ByteDance','ShowMeAI','Taobao','Tencent']aList弹出元素:TencentaList使用remove删除第一个匹配的ShowMeAI:['Baidu','google','DiDi','ByteDance','ShowMeAI','Taobao']aListresul使用reverse进行反向排序后的ts:['Taobao','ShowMeAI','ByteDance','DiDi','google','Baidu']aList使用sort排序后的结果:['Baidu','ByteDance',