zltzlt 发表于 2020-4-5 13:06:34

Python 实现 itertools.product

Python 实现 itertools.product

上代码:

class product:
    def __init__(self, *iterables, repeat=1):
      res = [[]]
      for item in * repeat:
            res = for x in res for y in item]
      self.__it = res.__iter__()

    def __iter__(self):
      return self

    def __next__(self):
      return tuple(self.__it.__next__())

如果代码有问题,欢迎在评论区指正{:10_311:}
页: [1]
查看完整版本: Python 实现 itertools.product