记录insert的用法
标准是:
L.insert(index, object)
index:对象obj需要插入的索引值
object:要插入列表中的对象
如:
L1 = ['Google', 'Runoob', 'Taobao']
L1.insert(1, 'Baidu')
print(L1)
>>>['Google', 'Runoob', 'Taobao', 'Baidu']
特别注意一点****
L1 = ['Google', 'Runoob', 'Taobao']
L1.insert(0, 'Baidu')
print (L1)
>>>['Baidu','Google', 'Runoob', 'Taobao']
L1.insert(0, '360')
print (L1)
>>>['360','Baidu','Google', 'Runoob', 'Taobao']
插入的位置选择为0
的话,可以用来倒排序,这是一个很好的方法
参考leetcode103
地址