本文共 501 字,大约阅读时间需要 1 分钟。
Following is the syntax for pop() method −
list.pop(obj=list[-1])
obj -- This is an optional parameter, index of the object to be removed from the list.
This method returns the removed object from the list.
The following example shows the usage of pop() method.
#!/usr/bin/pythonaList = [123, 'xyz', 'zara', 'abc'];print "A List : ", aList.pop()print "B List : ", aList.pop(2)
When we run above program, it produces following result −
A List : abcB List : zara
转载地址:http://yshbi.baihongyu.com/