Python `for` does not iterate over enumerate object

前端 未结 4 1799
日久生厌
日久生厌 2021-01-28 02:56

Why does this not iterate?

import logging
logging.basicConfig(level=logging.DEBUG)

x = []
y = [[] for n in range(0, 1)]
linedata = [\"0\",\"1\",\"2\"]
x.append(         


        
4条回答
  •  时光取名叫无心
    2021-01-28 03:30

    this line :

    logging.debug( list(e) )
    

    consumes the iterator, so when you get here:

    for k, v in e:
       # ...
    

    e is already exhausted.

提交回复
热议问题