# 链表
cars = ['a', "b"] print(cars)
# 链表长度
print(len(cars)) # 结尾添加元素
cars.append("c")
cars.append("d")
print(cars) # 指定位置添加元素
cars.insert(, "hello")
print(cars) # 查找元素位置
print(cars.index('hello')) # 链表末尾弹出元素
cars.pop()
print(cars)
cars.pop()
print(cars) # 删除链表的元素
cars.remove("b")
print(cars) # 排序
cars.sort()

result:

['a', 'b']

['a', 'b', 'c', 'd']
['a', 'b', 'hello', 'c', 'd'] ['a', 'b', 'hello', 'c']
['a', 'b', 'c']
['a', 'c']
05-11 22:27