감동, 마음이 움직이는 것

[python] dictionary key바꾸기 dic[newkey] = dic.pop(oldkey) 본문

Tips (Utility, Computer Language, and etc.)

[python] dictionary key바꾸기 dic[newkey] = dic.pop(oldkey)

Struggler J. 2017. 12. 22. 22:27

https://stackoverflow.com/questions/30720673/renaming-the-keys-of-a-dictionary

>>> dic = {}

>>> dic["a"] = 10

>>> dic["b"] = 19

>>> dic

>>> {'a':10, 'b':19}

>>> dic["c"] = dic.pop("a")

>>> dic

>>> {'c':10, 'b':19}