python 列表の常用操作
阿新 • • 發佈:2020-12-29
len(A_list)
A_list.append(strB)
A_list.insert(index,strB)
del A_list[index]
(刪除A_list列表中索引index處的元素)A_list.pop(index)
(刪除A_list列表中索引index處的元素並返回,若index為空則刪除並返回列表末尾元素)A_list.remove(strB)
(刪除A_list列表中值為strB的元素)A_list.sort()
(預設按照首字母大小順序排序)A_list.sort(reverse = True)
:按照首字母大小的相反順序排序。sorted(A_list)
A_list.reverse()
(永久性的修改,再呼叫方法reverse()即可恢復)