loops - Python Iterator: reset iterator? -


इस सवाल का पहले से ही एक उत्तर है: < / P>

  • 10 उत्तर

क्या आप इसे रीसेट कर सकते हैं? या फिर इसके माध्यम से फिर से बिना अगले तत्व को बचाने का एक तरीका है?

आप Itertools.tee एक इटरेटर के पिछले मानों को "याद रखना"

  & gt; & gt; & gt; तेरटोल्ट से आयात टी, izip & gt; & gt; & gt; यह = आईटर ([0,1, -13,8,4,3,5,4,3,8]) & gt; & gt; & gt; It1, it2, it3 = टी (यह, 3) & gt; & gt; & gt; अगला (यह 2) 0>> gt; & gt; अगला (यह 3) 0> gt; & gt; & gt; अगले (it3) 1> और gt; & gt; & gt; [जम्मू के लिए, जे, कश्मीर में izip (it1, it2, it3) अगर मैं & lt; ज & gt; K] [1, 8, 5]  

Comments

Popular posts from this blog

HTML/CSS - Automatically set height width from background image? -

php - Mysql Show Process - Sleep Commands and what to do -

c - What is the address of buf (the local variable in the main function)? -