代码改变世界

列表使用

2020-03-15 22:58  petty  阅读(141)  评论(0)    收藏  举报

列表的函数使用:

append('a')  往列表末尾添加

extends(['a','b']) +   往列表添加列表 

insert(index, 'a')  指定位置添加,其他完后移

sorted(list, reverse=False)  排序 默认升序,reverse=True降序

 

del lisnt[index]

remove('a')

pop()  移除列表最后一个元素

clear()