我有以下情况: List[i][j] 如下所示:
[['Motorized', 'Motorize', 'Motoriz', 'Motori', 'Motor', 'Moto', 'Mot', 'Mo', 'M'],
['wheel', 'whee', 'whe', 'wh', 'w'],
['chair', 'chai', 'cha', 'ch', 'c']]
我想尽可能组合所有订单中的所有值,例如:
Motorized wheel chair, M wheel c, ...
是否有内置函数可以执行此操作?关于该列表可以有任何维度。
请您参考如下方法:
这就是itertools.product用于:
lst = [['Motorized', ...] ... ]
for combination in itertools.product(*lst):
print ' '.join(combination)
