簡體   English   中英

如何從 itertools.product 獲取索引

[英]How to get index from itertools.product

# loop through every NxN cell in the target image
    for (blk_row, blk_col) in itertools.product(xrange(0, height - 
      (cell_size - 1), cell_size), xrange(0, width - (cell_size - 1), cell_size)):

其中 N = cellsize,除以 cellsize 以獲得索引是否有效?

要獲取任何迭代器的索引,請使用enumerate

for index, (blk_row, blk_col) in enumerate(itertools.product(
                                           xrange(0, height - (cell_size - 1), cell_size), 
                                           xrange(0, width - (cell_size - 1), cell_size))):

除以 cell_size 似乎有效,手指交叉。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM