如何在Python中使用insert() [英] How do you use insert() in Python
本文介绍了如何在Python中使用insert()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
myList = ["l","r","e"]
myList.insert("x")
我知道使用insert时需要两个参数,但是 我应该通过的第二个论点是什么?
I know that when using insert you need two arguments ,but what is the second argument I should pass?
推荐答案
第一个参数是插入元素的位置.第二个参数是元素.
The first argument is the position to insert the element. The second argument is the element.
>>> myList = ["l", "r", "e"]
>>> myList.insert(0, "a")
['a', 'l', 'r', 'e']
这篇关于如何在Python中使用insert()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文