列表功能
Posted 200ML
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了列表功能相关的知识,希望对你有一定的参考价值。
out = [‘play‘,‘wom‘,‘nuw‘,‘获取指定元素索引位置‘] out.append(‘追加‘) print(out) t = out.count(‘元素出现的次数‘) print(t) temp = [‘批量‘,‘添加‘] out.extend(temp) print(out) r = out.index(‘获取指定元素索引位置‘) print(r) out.insert(2,‘向指定索引位置插入数据‘) print(out) ‘‘‘移除列表中最后一个元素,并将其赋值給一个变量‘‘‘ w = out.pop() print(w) out.append(w) print(out) ‘‘‘移除某个元素‘‘‘ out.remove(‘play‘) print(out) ‘‘‘翻转‘‘‘ out.reverse() print(out)
‘‘‘删除指定索引位置‘‘‘
del out[1]
print(out)
以上是关于列表功能的主要内容,如果未能解决你的问题,请参考以下文章