Ejemplo 1: Python eliminar clave de dict
del dictionary['key']
Ejemplo 2: Python eliminar clave del diccionario
>>> # initialise a dictionary with the keys “city”, “name”, “food”
>>> person1_information = {'city': 'San Francisco', 'name': 'Sam', "food": "shrimps"}
>>> # delete the key, value pair with the key “food”
>>> del person1_information["food"]
>>> # print the present personal1_information. Note that the key, value pair “food”: “shrimps” is not there anymore.
>>> print(person1_information)
{'city': 'San Francisco', 'name': 'Sam'}
Ejemplo 3: eliminar elemento del diccionario python
dict.pop("key")
¡Haz clic para puntuar esta entrada!
(Votos: 0 Promedio: 0)