Python:想用循环替换itertool

时间:2015-11-30 10:18:50

标签: python loops

我有以下代码:

 for (r, c) in itertools.product(range(-1, 2), repeat=2):
        # don't search this square
        if r == 0 and c == 0:
            continue
        if self.row+r < 0 or self.row+r >= board.ROWS:
            continue
        if self.col+c < 0 or self.col+c >= board.COLS:
            continue
        yield ((self.row+r), (self.col+c))

我想做的就是使用循环而不是使用itertool来查找产品。

0 个答案:

没有答案