In this article we will learn about the python pop function in the python dictionary. What does the pop function in python mean? What does this function do? All will be answered in the following articles.
python pop function description
Python dictionary pop() method deletes the value corresponding to the given key key in the dictionary, and the return value is the deleted value. The key value must be given. Otherwise, return the default value.
Syntax
pop(key[,default])
Parameters
Return value
Returns the deleted value.Python pop function example
The following example shows how to use the pop() method:#!/usr/bin/python # -*- coding: UTF-8 -*- site= {'name': '蓝天白云', 'alexa': 10000, 'url': 'www.runoob.com'} pop_obj=site.pop('name') print pop_obj # 输出 :蓝天白云
Python tutorial column on the php Chinese website.
The above is the detailed content of Definition and usage of python pop function (example demonstration). For more information, please follow other related articles on the PHP Chinese website!