首先引用下pythondoc

pop(key[, default])
If key is in the dictionary, remove it and return its value, else return default. If default is not given and key is not in the dictionary, a KeyError is raised.

然后是例子

default = dic(a='a', b='b', c='c')
k = default.pop(a) # k='a'
k = default.pop(b, 'sss') # k='b'
k = default.pop(d) # Error
k = default.pop(n, 'sss') # k='sss'

相关文章:

  • 2022-01-08
  • 2021-08-25
  • 2021-08-31
  • 2021-10-16
  • 2021-09-14
  • 2021-09-10
猜你喜欢
  • 2021-10-11
  • 2022-12-23
  • 2022-02-07
  • 2022-12-23
  • 2022-02-28
  • 2022-12-23
  • 2021-11-17
相关资源
相似解决方案