📜  添加到列表中间 python 代码示例

📅  最后修改于: 2022-03-11 14:46:43.246000             🧑  作者: Mango

代码示例1
# To insert an item at the 4th index of a list:

myList = [1, 2, 3, 4, 5]
insertThis = 5

# First argument is the index, second is what you wish to add.
myList.insert(3, insertThis)

print(myList)
# >>> [1, 2, 3, 5, 4, 5]