我正在编写一个代码,它应该遍历regu行并创建所有排列(1)每个协议使用哪些行,以及(2)为了检查某些功能而断开哪些行。你知道吗
reg_lines = {'primary': ['ETH', 'UDP', 'TCP'], 'secondary': ['ETH', 'TCP'], private': ['UDP', 'TCP']}
预期排列:
1。你知道吗
use = [{'primary':'ETH'}]
disc = [{'primary':'ETH'}]
2。你知道吗
use = [{'primary: 'TCP'}]
disc = [{'primary: 'TCP'}]
。。。你知道吗
j
use = [{'secondary: 'TCP'}]
disc = [{'secondary: 'TCP'}]
。。。你知道吗
一
use = [{'primary': 'ETH', 'secondary': 'ETH'}
disc = [{'primary': 'ETH'}]
我+1。你知道吗
use = [{'primary': 'ETH', 'secondary': 'ETH'}]
disc = [{'primary': 'ETH'}]
我+2。你知道吗
use = [{'primary': 'ETH', 'secondary': 'ETH'}]
disc = [{'primary': 'ETH', 'secondary': 'ETH'}]
。。。你知道吗
n
use = [{'primary': 'TCP', 'secondary': 'TCP', 'private': 'TCP}]
disc = [{'primary': 'TCP', 'secondary': 'TCP', 'private': 'TCP}]
首先,使用
itertools.combinations
获取主、次和私有的所有组合,然后使用itertools.product
获取这些组合的乘积。然后再次使用itertools.combinations
获取disc
字典的所有子集。你知道吗输出:
相关问题 更多 >
编程相关推荐