list.insert(index, object)
实例以下:html
#!/usr/bin/python3 a = ['abc', '2019_11', 'pople'] others = {'name': 'jack'} a.insert(-1, 'python') # 在列表末尾以前插入字符串对象(没法添加新的对象到列表末尾) a.insert(1, others) # 在索引值为1的对象以前插入others print("New list: " + str(a))
输出:python
New list: ['abc', {'name': 'jack'}, '2019_11', 'python', 'pople']