python 字符串的排列组合,可重复匹配

    技术2022-08-11  89

    此代码来自知乎某评论下的大神发言,python一行流,装逼必备。

    from functools import reduce a, b = ['A','C','T', 'G'], 5 # 4种字符,匹配5种字符 print(reduce(lambda x, y:[z0 + z1 for z0 in x for z1 in y], [a] * b))

    Processed: 0.013, SQL: 9