Dictionary Methods
| Method | Description |
|---|---|
get(key[, default]) | Safe value lookup |
keys() | View of keys |
values() | View of values |
items() | View of (key, value) pairs |
update(other) | Merge another mapping |
pop(key[, default]) | Remove key and return value |
popitem() | Remove and return an arbitrary pair |
setdefault(key[, default]) | Get or insert default |
clear() | Remove all items |
copy() | Shallow copy |
Example
d = {"a": 1}
print(d.get("b", 0))
d.update({"b": 2})
print(d)