创建可能案例的简单方法 [英] Simple way to create possible case
本文介绍了创建可能案例的简单方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有数据列表,例如
a = [1,2,3,4]
b = ["a","b","c","d","e"]
c = ["001","002","003"]
我想创建一个新的另一个列表,该列表是从像这样的a,b,c的所有可能情况中混合而成的
And I want to create new another list that was mixed from all possible case of a,b,c like this
d = ["1a001","1a002","1a003",...,"4e003"]
有没有生成d的模块或方法,而无需写很多for循环?
Is there any module or method to generate d without write many for loop?
推荐答案
[''.join(str(y) for y in x) for x in itertools.product(a, b, c)]
这篇关于创建可能案例的简单方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文