Python List pop()方法
Python 教程
· 2019-02-02 22:28:10
描述
pop() 函数用于移除列表中的一个元素(默认最后一个元素),并且返回该元素的值。
语法
pop()方法语法:
list.pop([index=-1])
参数
- obj -- 可选参数,要移除列表元素的索引值,不能超过列表总长度,默认为 index=-1,删除最后一个列表值。
返回值
该方法返回从列表中移除的元素对象。
实例
以下实例展示了 pop()函数的使用方法:
实例
#!/usr/bin/python3
#coding=utf-8
list1 = ['Google', 'Codercto', 'Taobao']
list_pop=list1.pop(1)
print "删除的项为 :", list_pop
print "列表现在为 : ", list1
以上实例输出结果如下:
删除的项为 : Codercto 列表现在为 : ['Google', 'Taobao']
点击查看所有 Python 教程 文章: https://codercto.com/courses/l/8.html
Design Accessible Web Sites
Jeremy Sydik / Pragmatic Bookshelf / 2007-11-05 / USD 34.95
It's not a one-browser web anymore. You need to reach audiences that use cell phones, PDAs, game consoles, or other "alternative" browsers, as well as users with disabilities. Legal requirements for a......一起来看看 《Design Accessible Web Sites》 这本书的介绍吧!