内容简介:pop() 函数用于移除列表中的一个元素(默认最后一个元素),并且返回该元素的值。
描述
pop() 函数用于移除列表中的一个元素(默认最后一个元素),并且返回该元素的值。
语法
pop()方法语法:
list.pop(obj=list[-1])
参数
- obj -- 可选参数,要移除列表元素的对象。
返回值
该方法返回从列表中移除的元素对象。
实例
以下实例展示了 pop()函数的使用方法:
#!/usr/bin/python aList = [123, 'xyz', 'zara', 'abc']; print "A List : ", aList.pop(); print "B List : ", aList.pop(2);
以上实例输出结果如下:
A List : abc B List : zara
以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,也希望大家多多支持 码农网
猜你喜欢:- 理解实例方法、类方法、静态方法
- 【MyBatis源码分析】insert方法、update方法、delete方法处理流程(上篇)
- 【MyBatis源码分析】insert方法、update方法、delete方法处理流程(上篇)
- java:方法覆盖与方法重载
- 静态方法、实例化方法与线程安全
- JS数组方法总览及遍历方法耗时统计
本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们。
Introduction to Computation and Programming Using Python
John V. Guttag / The MIT Press / 2013-7 / USD 25.00
This book introduces students with little or no prior programming experience to the art of computational problem solving using Python and various Python libraries, including PyLab. It provides student......一起来看看 《Introduction to Computation and Programming Using Python》 这本书的介绍吧!