티스토리 뷰

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

'공부' 카테고리의 다른 글

[Python] for k, v in map.items()  (0) 2022.04.30
[Github] AutoLinked references  (0) 2022.04.29
[Jinja Template]  (0) 2022.04.27
[JWT] Json Web Token  (0) 2022.04.26
[Kafka] acks=1; acks=all(-1), RF=3, min.insync.replicas=2  (0) 2022.04.26
댓글