“Python Change Dict Key Valor” Respostas de código

Python muda uma chave em um dicionário

# Basic syntax:
# Approach 1:
dictionary[new_key] = dictionary[old_key]
del dictionary[old_key]

# Approach 2:
dictionary[new_key] = dictionary.pop(old_key)
Charles-Alexandre Roy

Como mudar a chave para o valor e versa no Python Dictionary

dict = {value:key for key, value in dict.items()}
Odd Okapi

Python Change Dict Key Valor

# an example of creating a new dict key from an existing one, then deleting the old key
d = {"cow": "animal", "rose": "flower"}
d["horse"] = d["cow"]
del d["cow"]
Angry Alligator

Respostas semelhantes a “Python Change Dict Key Valor”

Perguntas semelhantes a “Python Change Dict Key Valor”

Mais respostas relacionadas para “Python Change Dict Key Valor” em Python

Procure respostas de código populares por idioma

Procurar outros idiomas de código