Advertisement
Guest User

Untitled

a guest
Mar 18th, 2019
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. {'id': ['001', '002', '003'], 'tag1': ['val1']}
  2.  
  3. [{'id': '001', 'tag1': 'val1'}, {'id': '002', 'tag1': 'val1'}, {'id': '003', 'tag1': 'val1'}]
  4.  
  5. pfilter = dict()
  6. pfilter["id"] = ["001", "002", "003"]
  7. pfilter["tag1"] = ["val1"]
  8. print(pfilter)
  9.  
  10. all_values = list(itertools.product(*pfilter.values()))
  11. all_keys = [pfilter.keys()]*len(all_values)
  12. all_dict = [zip(keys, values) for keys, values in zip(all_keys, all_values)]
  13. all_dict = [{k:v for k, v in item} for item in all_dict]
  14. print(all_dict)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement