pythonpop什么意思
python中的pop:
pop()函数的作用就是用来移除列表中的一个元素(默认最后一个元素),并且返回该元素的值。
语法
pop()方法语法:
list.pop(obj=list[-1])
参数
obj--可选参数,要移除列表元素的对象。
返回值
该方法返回从列表中移除的元素对象。
实例
以下实例展示了pop()函数的使用方法:
#!/usr/bin/python
aList=[123,'xyz','zara','abc'];
print"AList:",aList.pop();
print"BList:",aList.pop(2);
以上实例输出结果如下:
AList:abc
BList:zara
以上内容为大家介绍了python培训之pop什么意思,希望对大家有所帮助,如果想要了解更多Python相关知识,请关注IT培训机构:千锋教育。

相关推荐HOT
更多>>
pythonpython对大小写敏感吗?
python对大小写是敏感的,也就是说,python中是区分大小写的。Python的变量名是区分大小写的,例如:name和Name就是两个变量名,而非相同变量。...详情>>
2023-11-09 23:57:19
python单引号怎么打
实际上在Python中'...'和"..."是完全一样的,但不能出现'..."和"...'这种情况。而将其混合使用会有很多意想不到的效果:具体规...详情>>
2023-11-09 22:41:18
pythonpop什么意思
python中的pop:pop()函数的作用就是用来移除列表中的一个元素(默认最后一个元素),并且返回该元素的值。语法pop()方法语法:list.pop(obj=list...详情>>
2023-11-09 20:54:42
python怎么循环输入
python中的循环语句,可使用for循环,或者while循环。两者的区别是,for循环要求提前知道要循环的次数,而while循环只要满足条件就会循环,直到...详情>>
2023-11-09 16:48:15