Python list method(1)

Contributor:知乎:三生万物【标签:老朽意识】 Type:代码 Date time:2020-06-26 13:16:34 Favorite:14 Score:0
返回上页 Report
请选择举报理由:




Collection Modify the typo
> my_list = ["one","two"]
> my_list.append("three")#["one","two","three"]
Add an item to the end of the list. Equivalent to a[len(a):] = [my_list].
> my_list.remove("two")#["one","three"]
Remove the first item from the list whose value is equal to "twp".
> my_list.extend([1,3])#["one","three",1,3]
Extend the list by appending all the items from the [1,3](iterable). Equivalent to a[len(a):] =
[1,3]
> my_list.pop(2)#["one","three",3]
Remove the item at the given position in the list, and return it.
If no index is specified, my_list.pop() removes and returns the last item in the list.
> my_list.clear()#[]
Remove all items from the list. Equivalent to del my_list[:].
> my_list.insert(0, "haha")#["haha"]
Insert an item at a given position. The first argument is the index of the
element before which to insert, so a.insert(0, x) inserts at the front of the list,
and a.insert(len(a), x) is equivalent to a.append(x).
It raises a ValueError if there is no such item.
声明:以上文章均为用户自行添加,仅供打字交流使用,不代表本站观点,本站不承担任何法律责任,特此声明!如果有侵犯到您的权利,请及时联系我们删除。
Hot degree:
Difficulty:
quality:
Description: the system according to the heat, the difficulty, the quality of automatic certification, the certification of the article will be involved in typing!

This paper typing ranking TOP20

登录后可见