由买买提看人间百态

topics

全部话题 - 话题: prodtuples
(共0页)
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
(共0页)