Python辞書dict.fromkeys
copy

dict.fromkeys辞書

in 연산자

キーのイテラブルから新しいディクショナリを作成します。

문법

dict.fromkeys(iterable, value?)

예제

아래 값을 입력하면 예제에 즉시 반영됩니다.

keys
dict
fromkeys
print
keys = ["a", "b", "c"]
d = dict.fromkeys(keys, 0)
print(d)  # {'a': 0, 'b': 0, 'c': 0}