[問題] 請問一行code .next()
請問一行python code 版本是2.7
start = (n for n, e in graph.iteritems() if len(e) == 1).next()
^^^^^^
graph是一個dictionary type的object
請問後面的.next()的用途是什麼呢?
我有上網查了文件一下
他寫
Retrieve the next item from the iterator by calling its next() method. If
default is given, it is returned if the iterator is exhausted, otherwise
StopIteration is raised.
小弟我看不太懂 >"<
把next()拿掉也會出錯
有請好心人幫我解惑了...感恩
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 1.172.61.182
推
11/13 19:50, , 1F
11/13 19:50, 1F
→
11/13 19:50, , 2F
11/13 19:50, 2F
→
11/13 20:35, , 3F
11/13 20:35, 3F
Python 近期熱門文章
PTT數位生活區 即時熱門文章