模块五 python常用数据结构

列表

append
insert
list = [1,2,3,4,5]
"""
append 在尾部增加
insert可以定义在哪个位置参加

"""
list.append(8)
print(list)
list.insert(0,"a")
print(list)
输出结果:

[1, 2, 3, 4, 5, 8]
['a', 1, 2, 3, 4, 5, 8]

remove
list = [1,2,3,4,5]
"""
append 在尾部增加
insert可以定义在哪个位置参加
list.remove(值,不是索性)
"""
list.insert(0,"a")
list.remove(3)
print(list)

pop  是根据列表的索性删除,会返回被删除的值

 

posted on 2021-01-16 22:12  Cc01  阅读(52)  评论(0编辑  收藏  举报

导航