📜  python 更改字典中的键 - Python 代码示例

📅  最后修改于: 2022-03-11 14:46:09.752000             🧑  作者: Mango

代码示例3
>>> dictionary = { 1: 'one', 2:'two', 3:'three' }
>>> dictionary['ONE'] = dictionary.pop(1)
>>> dictionary
{2: 'two', 3: 'three', 'ONE': 'one'}
>>> dictionary['ONE'] = dictionary.pop(1)
Traceback (most recent call last):
  File "", line 1, in 
KeyError: 1