Problem: get value from key with default value.
Solution:
test_dict = {'test1': 'test1', 'test2':'test2', 'test3':'test3'} test_dict.get('nonkey', 'default')
-> 'default'
URL: https://wikidocs.net/16
'Python' 카테고리의 다른 글
[Python] 딕셔너리의 키와 기본 값을 저장하기 (0) | 2022.03.24 |
---|---|
[Python] 문자열 리스트를 정수 리스트로 변환 (0) | 2022.03.24 |
[Python] 두 딕셔너리의 합 구하기 (0) | 2022.02.08 |
[Python] requests User-Agent 설정하기 (0) | 2021.12.28 |
[Python] list, set, dict, tuple (0) | 2021.12.22 |