跳转至

🔥AI副业赚钱星球

点击下面图片查看

郭震AI

85

编辑日期: 2024-11-28 文章阅读:

@author jackzhenguo
@desc 
@date 2019/5/5

85 product 案例

def product(*args, repeat=1):
    pools = [tuple(pool) for pool in args] * repeat
    result = [[]]
    for pool in pools:
        result = [x+[y] for x in result for y in pool]
    for prod in result:
        yield tuple(prod)

调用函数:

rtn = product('xyz', '12', repeat=3)
print(list(rtn))

上一个例子 下一个例子

京ICP备20031037号-1