如果它的键存在,我需要一种获取字典值的方法,或者None如果不存在则需要返回.
None
但是,KeyError如果搜索不存在的密钥,Python会引发异常.我知道我可以检查密钥,但我正在寻找更明确的东西.None如果密钥不存在,有没有办法返回?
KeyError
python dictionary key nonetype
dictionary ×1
key ×1
nonetype ×1
python ×1