x = [1,2,3,4]
for i in x:
if i==2:
pass #Pass actually does nothing. It continues to execute statements below it.
print "This statement is from pass."
for i in x:
if i==2:
continue #Continue gets back to top of the loop.And statements below continue are executed.
print "This statement is from continue."
उत्पादन
>>> This statement is from pass.
फिर दें मामूली परिवर्तन के साथ एक ही कोड चल रहा है।
x = [1,2,3,4]
for i in x:
if i==2:
pass #Pass actually does nothing. It continues to execute statements below it.
print "This statement is from pass."
for i in x:
if i==2:
continue #Continue gets back to top of the loop.And statements below continue are executed.
print "This statement is from continue."
उत्पादन होता है -
>>> This statement is from pass.
This statement is from pass.
This statement is from pass.
This statement is from pass.
This statement is from continue.
This statement is from continue.
This statement is from continue.
पास कुछ भी नहीं है। गणना अप्रभावित है। लेकिन अगले गणना के साथ प्राप्त करने के लिए लूप के शीर्ष पर वापस आना जारी रखें।
स्रोत
2017-11-07 16:19:59
@ एसएलओटी: उदाहरण: 'जबकि सत्य :; पास करें [कीबोर्ड पाउडर] में कीबोर्ड इंटरप्ट (Ctrl + C) 'के लिए व्यस्त-प्रतीक्षा करें (http://docs.python.org/tutorial/controlflow.html#pass-statements) ने मुझे रास्ते में भ्रमित कर दिया, मैंने किया यह स्पष्ट मौसम नहीं ढूंढता है यह इस मामले में जारी रखने के बराबर व्यवहार करता है या कुछ और इरादा था। पहली वाक्य * "पास स्टेटमेंट कुछ भी नहीं करता है।" * मेरे प्रश्न के सभी उत्तरों की विशेषता है, लेकिन किसी भी तरह से यह मेरी आंख को पकड़ नहीं पाया। – Aufwind