Python辞書get
map

get辞書

keys

キーに対応する値を返します(キーがなければデフォルト値)。

構文

dict.get(key, default?)

使用例

下記の値を入力するとサンプルに即時反映されます。

person
print
get
Alice
None
person = {"name": "Alice", "age": 30}
print(person.get("name"))          # Alice
print(person.get("email"))         # None
print(person.get("email", "N/A"))  # N/A