공부
[Python] map[key] vs map.get(key, [default])
승가비
2022. 4. 29. 23:51
728x90
d = dict()
d.get('xyz', 42) # returns 42
https://stackoverflow.com/questions/30363550/python-dict-getkey-versus-dictkey
Python dict.get('key') versus dict['key']
Why does this throw a KeyError: d = dict() d['xyz'] But this does not? d = dict() d.get('xyz') I'm also curious if descriptors play a role here.
stackoverflow.com
728x90