Python 实现字典的一个Key(键)对应多个Value(值)

python中,字典是一个key对应一个value,当我们需要一个key对应多个value,可采用collections模块的defaultdict来实现:

代码

from collections import defaultdict
dict_one_to_more = defaultdict(list)
for x in range(10)
	dict_one_to_more["Key"]

你可能感兴趣的:(Python,字典,Python)