python 复杂的列表排列成字典

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了python 复杂的列表排列成字典相关的知识,希望对你有一定的参考价值。

import itertools
name = None
version = None
task = None
tag = None
permut_list = []
a = [["latest","not_latest","all"],[name is None, name is not None],[version is None, version is not None], [task is None, task is not None], [tag is None, tag is not None]]
permuts = list(itertools.product(*a))
keys = ['published', "name", "version", "task", "tag"]
for x in permuts:
    my_dict = dict(zip(keys, x))
    permut_list.append(my_dict)
print(permut_list)

以上是关于python 复杂的列表排列成字典的主要内容,如果未能解决你的问题,请参考以下文章