2019-03-18
阅读量:
510
Python列表可不可以删除特定列表?
python中的列表结合了数组和链表的最佳方面。
Python列表提供了删除特定元素的独特功能,同时保持内存位置的连续方式。此功能使链接列表的概念无效。就像STEROIDS上的链表一样!此外,插入可以在任何期望的位置执行。
# Python code to demonstrate list operations
arr = [00, 11, 22, 33, 44, 55, 66, 77, 88, 99]
# deletion via index position
del arr[5]
print(arr)
# deletion via specifying particular element
arr.remove(22)
print(arr)
# insertion at any arbitrary position
arr[-1] = "A random number"
print(arr)
# concept of sub-lists
k = arr[:2]
print(k)
输出:
[0,11,22,33,44,66,77,88,99]
[0,11,33,44,66,77,88,99]
[0,11,33,44,66,77,88,'random']
[0,11]






评论(0)


暂无数据
推荐帖子
0条评论
0条评论
0条评论