#pop()列表方法删除(弹出)列表末尾的元素(对象)
poped_ele = list1.pop()print(f"The poped element is {poped_ele}!")print(f"The current list1 is {list1}")#pop(n)可以从列表中部分弹出下标为n的元素print(f"The 2th([1]) element 'kate' will be poped,the result is {list1.pop(1)} ")
The poped element is 233!
The current list1 is ['tom', 'kate', 'Lili']
The 2th([1]) element 'kate' will be poped,the result is kate
print(f"The current list1 is {list1}")
The current list1 is ['tom', 'Lili']
#remove()列表方法根据值删除列表中的元素
list1.remove("tom")print(f"The current list1 is {list1}")
The current list1 is ['Lili']
#sort()列表方法对列表进行默认永久排序(升)
list2 =["d","a","c","b"]
list2.sort()print(f"The sorted list2 is {list2}")#reverse参数决定升降序,True则降序