d******e 发帖数: 2265 | 1 考试嘛?上一段real code
def parameterprod(paradict):
keys = tuple(paradict.keys())
itemlist = []
for k in paradict.keys():
if isinstance(paradict[k], list):
itemlist.append( paradict[k])
else:
l = []
l.append(paradict[k])
itemlist.append(l)
prodtuples = list(itertools.product(*itemlist))
pdict = []
for l in prodtuples:
pdict.append(dict(zip(keys,l)))
return pdict |
|