PythonDictionarydict.fromkeys
copy

dict.fromkeysDictionary

in 연산자

Creates a new dictionary from an iterable of keys with an optional default value.

문법

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}