我有一个空的“numpy.ndarray”
import numpy as np
my_grid = np.zeros((5, 5))
parse = "max","min","avg"
我希望创建一个字典,其中 parse 的每个元素都是“键”
从集合导入 defaultdict
GridMetric = dict()
for arg in parse:
GridMetric[arg].append(my_grid)
但我得到这个错误
Traceback (most recent call last):
File "<editor selection>", line 3, in <module>
KeyError: 'max'