python – 创建可能案例的简单方法

我有数据列表,如

a = [1,2,3,4]
b = ["a","b","c","d","e"]
c = ["001","002","003"]

我想创建一个新的另一个列表,混合了所有可能的a,b,c这样的情况

d = ["1a001","1a002","1a003",...,"4e003"]

有没有任何模块或方法来生成d而没有写多个for循环?

最佳答案
[''.join(str(y) for y in x) for x in itertools.product(a, b, c)]

转载注明原文:python – 创建可能案例的简单方法 - 代码日志