{"id":16539,"date":"2024-12-19T01:31:53","date_gmt":"2024-12-18T22:01:53","guid":{"rendered":"https:\/\/www.itpiran.net\/blog\/?p=16539"},"modified":"2024-12-19T01:31:53","modified_gmt":"2024-12-18T22:01:53","slug":"how-to-use-break-continue-and-pass-statements-when-working-with-loops-in-python-3-2","status":"publish","type":"post","link":"https:\/\/www.itpiran.net\/blog\/zh\/tutorials\/how-to-use-break-continue-and-pass-statements-when-working-with-loops-in-python-3-2\/","title":{"rendered":"\u5982\u4f55\u5728 Python \u4e2d\u4f7f\u7528\u5faa\u73af\u65f6\u4f7f\u7528 Continue\u3001Break \u548c Pass \u8bed\u53e5"},"content":{"rendered":"<h2 id=\"%d9%85%d9%82%d8%af%d9%85%d9%87\">\u4ecb\u7ecd<\/h2>\n<p>\u5728 Python \u4e2d\u4f7f\u7528 for \u5faa\u73af\u548c while \u5faa\u73af\u53ef\u4ee5\u81ea\u52a8\u9ad8\u6548\u5730\u91cd\u590d\u6267\u884c\u4efb\u52a1\u3002\u8fd9\u4e9b\u5faa\u73af\u662f Python \u7684\u57fa\u672c\u7ed3\u6784\uff0c\u5141\u8bb8\u4f60\u904d\u5386\u5217\u8868\u3001\u5143\u7ec4\u548c\u5b57\u7b26\u4e32\u7b49\u5e8f\u5217\uff0c\u6216\u8005\u6839\u636e\u6761\u4ef6\u91cd\u590d\u6267\u884c\u4e00\u6bb5\u4ee3\u7801\u3002.<\/p>\n<p>\u7136\u800c\uff0c\u5728\u67d0\u4e9b\u60c5\u51b5\u4e0b\uff0c\u4f60\u9700\u8981\u5bf9\u5faa\u73af\u6d41\u7a0b\u8fdb\u884c\u66f4\u7cbe\u7ec6\u7684\u63a7\u5236\u3002\u4f8b\u5982\uff0c\u4f60\u53ef\u80fd\u9700\u8981\u63d0\u524d\u9000\u51fa\u5faa\u73af\u3001\u8df3\u8fc7\u5f53\u524d\u8fed\u4ee3\uff0c\u6216\u8005\u4ec5\u4ec5\u4e3a\u540e\u7eed\u4ee3\u7801\u9884\u7559\u4e00\u4e2a\u5360\u4f4d\u7b26\u3002Python \u63d0\u4f9b\u4e86\u4e09\u4e2a\u5f3a\u5927\u7684\u8bed\u53e5\u6765\u5904\u7406\u8fd9\u4e9b\u60c5\u51b5\uff1a`break`\u3001`continue` \u548c `pass`\u3002.<\/p>\n<ul>\n<li>break \u8bed\u53e5\u5141\u8bb8\u4f60\u5728\u6ee1\u8db3\u7279\u5b9a\u6761\u4ef6\u65f6\u5b8c\u5168\u9000\u51fa\u5faa\u73af\uff0c\u4ece\u800c\u6709\u6548\u5730\u505c\u6b62\u5faa\u73af\u7684\u6267\u884c\u3002.<\/li>\n<li>break \u8bed\u53e5\u5141\u8bb8\u4f60\u5728\u6ee1\u8db3\u7279\u5b9a\u6761\u4ef6\u65f6\u5b8c\u5168\u9000\u51fa\u5faa\u73af\uff0c\u4ece\u800c\u6709\u6548\u5730\u505c\u6b62\u5faa\u73af\u7684\u6267\u884c\u3002.<\/li>\n<li>pass \u8bed\u53e5\u662f\u4e00\u4e2a\u7a7a\u8fd0\u7b97\u7b26\u3002\u5b83\u7528\u4f5c\u5faa\u73af\u3001\u51fd\u6570\u3001\u7c7b\u6216\u6761\u4ef6\u8bed\u53e5\u4e2d\u7684\u5360\u4f4d\u7b26\uff0c\u7528\u4e8e\u8868\u793a\u8bed\u6cd5\u4e0a\u9700\u8981\u7684\u4ee3\u7801\uff0c\u4f46\u5b9e\u9645\u4e0a\u6ca1\u6709\u4efb\u4f55\u4ee3\u7801\u9700\u8981\u6267\u884c\u3002.<\/li>\n<\/ul>\n<p>\u7406\u89e3\u5e76\u8fd0\u7528\u8fd9\u4e9b\u8bed\u53e5\u53ef\u4ee5\u663e\u8457\u63d0\u5347\u4f60\u7ba1\u7406\u5faa\u73af\u63a7\u5236\u6d41\u7684\u80fd\u529b\uff0c\u4f7f\u4f60\u7684\u4ee3\u7801\u66f4\u9ad8\u6548\u3001\u66f4\u6613\u8bfb\u3002\u5728\u63a5\u4e0b\u6765\u7684\u7ae0\u8282\u4e2d\uff0c\u6211\u4eec\u5c06\u901a\u8fc7\u5b9e\u9645\u793a\u4f8b\u6765\u63a2\u8ba8\u5982\u4f55\u5728 Python \u5faa\u73af\u4e2d\u4f7f\u7528 break\u3001continue \u548c pass \u8bed\u53e5\u3002.<\/p>\n<h5 id=\"%d9%be%db%8c%d8%b4-%d9%86%db%8c%d8%a7%d8%b2%d9%87%d8%a7\">\u5148\u51b3\u6761\u4ef6<\/h5>\n<p>\u60a8\u7684\u8ba1\u7b97\u673a\u6216\u670d\u52a1\u5668\u4e0a\u5fc5\u987b\u5b89\u88c5 Python 3 \u5e76\u5177\u5907\u5f00\u53d1\u73af\u5883\u3002\u5982\u679c\u60a8\u5c1a\u672a\u8bbe\u7f6e\u5f00\u53d1\u73af\u5883\uff0c\u53ef\u4ee5\u53c2\u8003\u5b89\u88c5\u548c\u8bbe\u7f6e\u6307\u5357\uff0c\u5728\u60a8\u7684\u670d\u52a1\u5668\u4e0a\u8bbe\u7f6e\u9002\u5408\u60a8\u64cd\u4f5c\u7cfb\u7edf\uff08Ubuntu\u3001CentOS\u3001Debian \u7b49\uff09\u7684\u672c\u5730 Python \u5f00\u53d1\u73af\u5883\u3002.<\/p>\n<h2 id=\"break-statement\">\u4e2d\u65ad\u58f0\u660e<\/h2>\n<p>\u5728 Python \u4e2d\uff0c`break` \u8bed\u53e5\u5141\u8bb8\u4f60\u5728\u5916\u90e8\u6761\u4ef6\u89e6\u53d1\u65f6\u9000\u51fa\u5faa\u73af\u3002`break` \u8bed\u53e5\u901a\u5e38\u653e\u5728\u5faa\u73af\u8bed\u53e5\u4e0b\u65b9\u7684\u4ee3\u7801\u5757\u4e2d\uff0c\u4e00\u822c\u4f4d\u4e8e `if` \u6761\u4ef6\u8bed\u53e5\u4e4b\u540e\u3002.<\/p>\n<p>\u8ba9\u6211\u4eec\u6765\u770b\u4e00\u4e2a\u5728 for \u5faa\u73af\u4e2d\u4f7f\u7528 break \u8bed\u53e5\u7684\u4f8b\u5b50\uff1a<\/p>\n<div class=\"hcb_wrap\" data-no-translation=\"\" data-no-auto-translation=\"\">\n<pre class=\"prism line-numbers lang-python\" data-lang=\"Python\"><code>number = 0\r\nfor number in range(10):\r\nif number == 5:\r\nbreak # break here\r\nprint('Number is ' + str(number))\r\nprint('Out of loop')<\/code><\/pre>\n<\/div>\n<p>\u5728\u8fd9\u4e2a\u5c0f\u7a0b\u5e8f\u4e2d\uff0c\u53d8\u91cf number \u88ab\u521d\u59cb\u5316\u4e3a 0\u3002\u7136\u540e\uff0c\u5982\u679c\u53d8\u91cf number \u5c0f\u4e8e 10\uff0c\u5219\u521b\u5efa\u4e00\u4e2a for \u5faa\u73af\u3002.<\/p>\n<p>\u5728 for \u5faa\u73af\u4e2d\uff0cif \u8bed\u53e5\u63d0\u4f9b\u4e86\u4e00\u4e2a\u6761\u4ef6\uff0c\u5f53\u53d8\u91cf number \u7b49\u4e8e\u6574\u6570 5 \u65f6\uff0c\u5faa\u73af\u5c06\u7ec8\u6b62\u3002\u6709\u5173\u4f7f\u7528 for \u5faa\u73af\u7684\u66f4\u591a\u4fe1\u606f\uff0c\u60a8\u53ef\u4ee5\u53c2\u8003\u8fd9\u7bc7\u5173\u4e8e\u5728 Python \u4e2d\u4f7f\u7528 for() \u5faa\u73af\u7684\u6559\u7a0b\u3002.<\/p>\n<p>\u5faa\u73af\u5185\u90e8\u8fd8\u6709\u4e00\u4e2a print() \u8bed\u53e5\uff0c\u5b83\u4f1a\u5728 for \u5faa\u73af\u7684\u6bcf\u6b21\u8fed\u4ee3\u4e2d\u6267\u884c\uff0c\u76f4\u5230\u5faa\u73af\u4e2d\u65ad\u4e3a\u6b62\uff0c\u56e0\u4e3a\u5b83\u4f4d\u4e8e break \u8bed\u53e5\u4e4b\u540e\u3002.<\/p>\n<p>\u8ba9\u6211\u4eec\u5728 for \u5faa\u73af\u4e4b\u5916\u6dfb\u52a0\u4e00\u4e2a\u6700\u7ec8\u7684 print() \u8bed\u53e5\uff0c\u4ee5\u4fbf\u6211\u4eec\u77e5\u9053\u4f55\u65f6\u8df3\u51fa\u5faa\u73af\u3002.<\/p>\n<p>\u8fd0\u884c\u8fd9\u6bb5\u4ee3\u7801\u540e\uff0c\u4f60\u4f1a\u5f97\u5230\u4ee5\u4e0b\u8f93\u51fa\uff1a<\/p>\n<div class=\"hcb_wrap\" data-no-translation=\"\" data-no-auto-translation=\"\">\n<pre class=\"prism line-numbers lang-plain\" data-lang=\"Plain Text\"><code>Output\r\nNumber is 0\r\nNumber is 1\r\nNumber is 2\r\nNumber is 3\r\nNumber is 4\r\nOut of loop<\/code><\/pre>\n<\/div>\n<p>\u8fd9\u8868\u660e\uff0c\u5f53\u8ba1\u7b97\u6574\u6570\u7b49\u4e8e 5 \u65f6\uff0c\u5faa\u73af\u5c31\u4f1a\u4e2d\u65ad\uff0c\u56e0\u4e3a\u7a0b\u5e8f\u901a\u8fc7 break \u8bed\u53e5\u88ab\u544a\u77e5\u8981\u8fd9\u6837\u505a\u3002.<\/p>\n<p>break \u8bed\u53e5\u4f7f\u7a0b\u5e8f\u9000\u51fa\u5faa\u73af\u3002.<\/p>\n<h2 id=\"continue-statement\">\u7ee7\u7eed\u58f0\u660e<\/h2>\n<p>continue \u8bed\u53e5\u5141\u8bb8\u4f60\u8df3\u8fc7\u5faa\u73af\u4e2d\u5916\u90e8\u6761\u4ef6\u89e6\u53d1\u7684\u90e8\u5206\uff0c\u4f46\u7ee7\u7eed\u6267\u884c\u5faa\u73af\u3002\u5faa\u73af\u7684\u5f53\u524d\u8fed\u4ee3\u4f1a\u88ab\u4e2d\u65ad\uff0c\u4f46\u7a0b\u5e8f\u4f1a\u8fd4\u56de\u5230\u5faa\u73af\u7684\u5f00\u5934\u3002.<\/p>\n<p>continue \u8bed\u53e5\u5c06\u653e\u7f6e\u5728 loop \u8bed\u53e5\u4e0b\u65b9\u7684\u4ee3\u7801\u5757\u4e2d\uff0c\u901a\u5e38\u4f4d\u4e8e if \u6761\u4ef6\u8bed\u53e5\u4e4b\u540e\u3002.<\/p>\n<p>\u4f7f\u7528\u4e0a\u9762 break \u8bed\u53e5\u90e8\u5206\u4e2d\u7684\u540c\u4e00\u4e2a for \u5faa\u73af\u7a0b\u5e8f\uff0c\u6211\u4eec\u5c06\u4f7f\u7528 continue \u8bed\u53e5\u4ee3\u66ff break \u8bed\u53e5\uff1a<\/p>\n<div class=\"hcb_wrap\" data-no-translation=\"\" data-no-auto-translation=\"\">\n<pre class=\"prism line-numbers lang-python\" data-lang=\"Python\"><code>number = 0\r\nfor number in range(10):\r\nif number == 5:\r\ncontinue # continue here\r\nprint('Number is ' + str(number))\r\nprint('Out of loop')<\/code><\/pre>\n<\/div>\n<p>\u4f7f\u7528 continue \u8bed\u53e5\u800c\u4e0d\u662f break \u8bed\u53e5\u7684\u533a\u522b\u5728\u4e8e\uff0c\u5f53\u53d8\u91cf number \u7684\u503c\u4e3a 5 \u65f6\uff0c\u5373\u4f7f\u4e2d\u65ad\u53d1\u751f\uff0c\u6211\u4eec\u7684\u4ee3\u7801\u4e5f\u4f1a\u7ee7\u7eed\u6267\u884c\u3002\u8ba9\u6211\u4eec\u6765\u770b\u4e00\u4e0b\u8f93\u51fa\u7ed3\u679c\uff1a<\/p>\n<div class=\"hcb_wrap\" data-no-translation=\"\" data-no-auto-translation=\"\">\n<pre class=\"prism line-numbers lang-plain\" data-lang=\"Plain Text\"><code>Output\r\nNumber is 0\r\nNumber is 1\r\nNumber is 2\r\nNumber is 3\r\nNumber is 4\r\nNumber is 6\r\nNumber is 7\r\nNumber is 8\r\nNumber is 9\r\nOut of loop<\/code><\/pre>\n<\/div>\n<p>\u5728\u8fd9\u91cc\uff0c\u6570\u5b57 5 \u4ece\u672a\u51fa\u73b0\u5728\u8f93\u51fa\u4e2d\uff0c\u4f46\u5faa\u73af\u5728\u6b64\u4e4b\u540e\u7ee7\u7eed\u6253\u5370\u6570\u5b57 6-10 \u7684\u884c\uff0c\u7136\u540e\u9000\u51fa\u5faa\u73af\u3002.<\/p>\n<p>\u60a8\u53ef\u4ee5\u4f7f\u7528 continue \u8bed\u53e5\u6765\u907f\u514d\u6df1\u5ea6\u5d4c\u5957\u7684\u6761\u4ef6\u4ee3\u7801\uff0c\u6216\u8005\u901a\u8fc7\u6d88\u9664\u8981\u8df3\u8fc7\u7684\u9879\u76ee\u6765\u4f18\u5316\u5faa\u73af\u3002.<\/p>\n<p>continue \u8bed\u53e5\u4f7f\u7a0b\u5e8f\u8df3\u8fc7\u5faa\u73af\u4e2d\u51fa\u73b0\u7684\u67d0\u4e9b\u5143\u7d20\uff0c\u4f46\u7ee7\u7eed\u6267\u884c\u5faa\u73af\u7684\u5176\u4f59\u90e8\u5206\u3002.<\/p>\n<h2 id=\"pass-statement\">\u901a\u8fc7\u58f0\u660e<\/h2>\n<p>\u5f53\u5916\u90e8\u6761\u4ef6\u89e6\u53d1\u65f6\uff0cpass \u8bed\u53e5\u5141\u8bb8\u4f60\u5728\u4e0d\u4ee5\u4efb\u4f55\u65b9\u5f0f\u5f71\u54cd\u5faa\u73af\u7684\u60c5\u51b5\u4e0b\u5904\u7406\u8be5\u6761\u4ef6\u3002\u9664\u975e\u53d1\u751f\u6545\u969c\u6216\u5176\u4ed6\u60c5\u51b5\uff0c\u5426\u5219\u6240\u6709\u4ee3\u7801\u5c06\u7ee7\u7eed\u8bfb\u53d6\u3002.<\/p>\n<p>\u4e0e\u5176\u4ed6\u8bed\u53e5\u4e00\u6837\uff0cpass \u8bed\u53e5\u5c06\u653e\u7f6e\u5728 loop \u8bed\u53e5\u4e0b\u9762\u7684\u4ee3\u7801\u5757\u4e2d\uff0c\u901a\u5e38\u4f4d\u4e8e if \u6761\u4ef6\u8bed\u53e5\u4e4b\u540e\u3002.<\/p>\n<p>\u4f7f\u7528\u4e0a\u9762\u76f8\u540c\u7684\u4ee3\u7801\u5757\uff0c\u8ba9\u6211\u4eec\u5c06 break \u6216 continue \u8bed\u53e5\u66ff\u6362\u4e3a pass \u8bed\u53e5\uff1a<\/p>\n<div class=\"hcb_wrap\" data-no-translation=\"\" data-no-auto-translation=\"\">\n<pre class=\"prism line-numbers lang-python\" data-lang=\"Python\"><code>number = 0\r\nfor number in range(10):\r\nif number == 5:\r\npass # pass here\r\nprint('Number is ' + str(number))\r\nprint('Out of loop')<\/code><\/pre>\n<\/div>\n<p>\u5728 if \u6761\u4ef6\u8bed\u53e5\u4e4b\u540e\uff0cpass \u8bed\u53e5\u544a\u8bc9\u7a0b\u5e8f\u7ee7\u7eed\u6267\u884c\u5faa\u73af\uff0c\u5e76\u5ffd\u7565\u53d8\u91cf number \u5728\u5176\u67d0\u6b21\u8fed\u4ee3\u671f\u95f4\u7684\u503c\u4e3a 5\u3002.<\/p>\n<p>\u8fd0\u884c\u7a0b\u5e8f\u540e\uff0c\u5f97\u5230\u4ee5\u4e0b\u8f93\u51fa\uff1a<\/p>\n<div class=\"hcb_wrap\" data-no-translation=\"\" data-no-auto-translation=\"\">\n<pre class=\"prism line-numbers lang-plain\" data-lang=\"Plain Text\"><code>Output\r\nNumber is 0\r\nNumber is 1\r\nNumber is 2\r\nNumber is 3\r\nNumber is 4\r\nNumber is 5\r\nNumber is 6\r\nNumber is 7\r\nNumber is 8\r\nNumber is 9\r\nOut of loop<\/code><\/pre>\n<\/div>\n<p>\u5728\u672c\u7a0b\u5e8f\u4e2d\u4f7f\u7528 pass \u8bed\u53e5\u540e\uff0c\u4f60\u4f1a\u53d1\u73b0\u7a0b\u5e8f\u7684\u6267\u884c\u65b9\u5f0f\u4e0e\u6ca1\u6709\u6761\u4ef6\u8bed\u53e5\u65f6\u5b8c\u5168\u76f8\u540c\u3002pass \u8bed\u53e5\u544a\u8bc9\u7a0b\u5e8f\u5ffd\u7565\u8be5\u6761\u4ef6\uff0c\u5e76\u7ee7\u7eed\u50cf\u5f80\u5e38\u4e00\u6837\u6267\u884c\u3002.<\/p>\n<p>pass \u8bed\u53e5\u53ef\u4ee5\u521b\u5efa\u6700\u5c0f\u7684\u7c7b\uff0c\u6216\u8005\u5728\u7f16\u5199\u65b0\u4ee3\u7801\u65f6\uff0c\u5728\u7b97\u6cd5\u5c42\u9762\u601d\u8003\u95ee\u9898\uff0c\u7136\u540e\u518d\u6572\u5b9a\u7ec6\u8282\u65f6\uff0c\u53ef\u4ee5\u7528\u4f5c\u5360\u4f4d\u7b26\u3002.<\/p>\n<h2 id=\"%d9%86%d8%aa%db%8c%d8%ac%d9%87\">\u7ed3\u679c<\/h2>\n<p>Python \u4e2d\u7684 break\u3001continue \u548c pass \u8bed\u53e5\u4f7f\u4f60\u80fd\u591f\u5728\u4ee3\u7801\u4e2d\u66f4\u6709\u6548\u5730\u4f7f\u7528 for \u548c while \u5faa\u73af\u3002.<\/p>","protected":false},"excerpt":{"rendered":"\u7b80\u4ecb\uff1a\u5728 Python \u4e2d\u4f7f\u7528 for \u5faa\u73af\u548c while \u5faa\u73af\u53ef\u4ee5\u5b9e\u73b0\u4efb\u52a1\u81ea\u52a8\u5316\u2026\u2026","protected":false},"author":1,"featured_media":16542,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_yoast_wpseo_focuskw":"Break \u0648 Continue \u0648 Pass \u062f\u0631 Python","_yoast_wpseo_title":"","_yoast_wpseo_metadesc":"","_yoast_wpseo_canonical":"","_yoast_wpseo_opengraph-description":"","_yoast_wpseo_opengraph-image":"","_yoast_wpseo_twitter-description":"","_yoast_wpseo_twitter-image":"","_yoast_wpseo_focuskeywords":"[]","_yoast_wpseo_primary_category":"193","footnotes":""},"categories":[193,363],"tags":[376],"class_list":{"0":"post-16539","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"has-post-thumbnail","7":"category-tutorials","8":"category-programming","9":"tag-python"},"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.3 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>\u0646\u062d\u0648\u0647 \u0627\u0633\u062a\u0641\u0627\u062f\u0647 \u0627\u0632 \u0639\u0628\u0627\u0631\u062a Continue\u060c Break \u0648 Pass \u0647\u0646\u06af\u0627\u0645 \u06a9\u0627\u0631 \u0628\u0627 \u062d\u0644\u0642\u0647 \u0647\u0627 \u062f\u0631 Python - \u0628\u0644\u0627\u06af ITPiran<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.itpiran.net\/blog\/zh\/tutorials\/how-to-use-break-continue-and-pass-statements-when-working-with-loops-in-python-3-2\/\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"\u0646\u062d\u0648\u0647 \u0627\u0633\u062a\u0641\u0627\u062f\u0647 \u0627\u0632 \u0639\u0628\u0627\u0631\u062a Continue\u060c Break \u0648 Pass \u0647\u0646\u06af\u0627\u0645 \u06a9\u0627\u0631 \u0628\u0627 \u062d\u0644\u0642\u0647 \u0647\u0627 \u062f\u0631 Python - \u0628\u0644\u0627\u06af ITPiran\" \/>\n<meta property=\"og:description\" content=\"\u0645\u0642\u062f\u0645\u0647 \u0627\u0633\u062a\u0641\u0627\u062f\u0647 \u0627\u0632 \u062d\u0644\u0642\u0647\u200c\u0647\u0627\u06cc for \u0648 \u062d\u0644\u0642\u0647\u200c\u0647\u0627\u06cc while \u062f\u0631 \u067e\u0627\u06cc\u062a\u0648\u0646 \u0628\u0647 \u0634\u0645\u0627 \u0627\u0645\u06a9\u0627\u0646 \u0645\u06cc\u200c\u062f\u0647\u062f \u0648\u0638\u0627\u06cc\u0641 \u0631\u0627 \u062e\u0648\u062f\u06a9\u0627\u0631 \u0648&hellip;\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.itpiran.net\/blog\/zh\/tutorials\/how-to-use-break-continue-and-pass-statements-when-working-with-loops-in-python-3-2\/\" \/>\n<meta property=\"og:site_name\" content=\"\u0628\u0644\u0627\u06af ITPiran\" \/>\n<meta property=\"article:published_time\" content=\"2024-12-18T22:01:53+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/cdn.itpiran.net\/2024\/12\/19013025\/Python-Break-Pass-Continue.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1793\" \/>\n\t<meta property=\"og:image:height\" content=\"1110\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"7 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.itpiran.net\\\/blog\\\/tutorials\\\/how-to-use-break-continue-and-pass-statements-when-working-with-loops-in-python-3-2\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.itpiran.net\\\/blog\\\/tutorials\\\/how-to-use-break-continue-and-pass-statements-when-working-with-loops-in-python-3-2\\\/\"},\"author\":{\"name\":\"admin\",\"@id\":\"https:\\\/\\\/www.itpiran.net\\\/blog\\\/#\\\/schema\\\/person\\\/04ed27b919baca468a2273f8e4318f81\"},\"headline\":\"\u0646\u062d\u0648\u0647 \u0627\u0633\u062a\u0641\u0627\u062f\u0647 \u0627\u0632 \u0639\u0628\u0627\u0631\u062a Continue\u060c Break \u0648 Pass \u0647\u0646\u06af\u0627\u0645 \u06a9\u0627\u0631 \u0628\u0627 \u062d\u0644\u0642\u0647 \u0647\u0627 \u062f\u0631 Python\",\"datePublished\":\"2024-12-18T22:01:53+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.itpiran.net\\\/blog\\\/tutorials\\\/how-to-use-break-continue-and-pass-statements-when-working-with-loops-in-python-3-2\\\/\"},\"wordCount\":68,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/www.itpiran.net\\\/blog\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.itpiran.net\\\/blog\\\/tutorials\\\/how-to-use-break-continue-and-pass-statements-when-working-with-loops-in-python-3-2\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/cdn.itpiran.net\\\/2024\\\/12\\\/19013025\\\/Python-Break-Pass-Continue.jpg\",\"keywords\":[\"Python\"],\"articleSection\":[\"\u0622\u0645\u0648\u0632\u0634\u06cc\",\"\u0628\u0631\u0646\u0627\u0645\u0647 \u0646\u0648\u06cc\u0633\u06cc\"],\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.itpiran.net\\\/blog\\\/tutorials\\\/how-to-use-break-continue-and-pass-statements-when-working-with-loops-in-python-3-2\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.itpiran.net\\\/blog\\\/tutorials\\\/how-to-use-break-continue-and-pass-statements-when-working-with-loops-in-python-3-2\\\/\",\"url\":\"https:\\\/\\\/www.itpiran.net\\\/blog\\\/tutorials\\\/how-to-use-break-continue-and-pass-statements-when-working-with-loops-in-python-3-2\\\/\",\"name\":\"\u0646\u062d\u0648\u0647 \u0627\u0633\u062a\u0641\u0627\u062f\u0647 \u0627\u0632 \u0639\u0628\u0627\u0631\u062a Continue\u060c Break \u0648 Pass \u0647\u0646\u06af\u0627\u0645 \u06a9\u0627\u0631 \u0628\u0627 \u062d\u0644\u0642\u0647 \u0647\u0627 \u062f\u0631 Python - \u0628\u0644\u0627\u06af ITPiran\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.itpiran.net\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.itpiran.net\\\/blog\\\/tutorials\\\/how-to-use-break-continue-and-pass-statements-when-working-with-loops-in-python-3-2\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.itpiran.net\\\/blog\\\/tutorials\\\/how-to-use-break-continue-and-pass-statements-when-working-with-loops-in-python-3-2\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/cdn.itpiran.net\\\/2024\\\/12\\\/19013025\\\/Python-Break-Pass-Continue.jpg\",\"datePublished\":\"2024-12-18T22:01:53+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.itpiran.net\\\/blog\\\/tutorials\\\/how-to-use-break-continue-and-pass-statements-when-working-with-loops-in-python-3-2\\\/#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.itpiran.net\\\/blog\\\/tutorials\\\/how-to-use-break-continue-and-pass-statements-when-working-with-loops-in-python-3-2\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\\\/\\\/www.itpiran.net\\\/blog\\\/tutorials\\\/how-to-use-break-continue-and-pass-statements-when-working-with-loops-in-python-3-2\\\/#primaryimage\",\"url\":\"https:\\\/\\\/cdn.itpiran.net\\\/2024\\\/12\\\/19013025\\\/Python-Break-Pass-Continue.jpg\",\"contentUrl\":\"https:\\\/\\\/cdn.itpiran.net\\\/2024\\\/12\\\/19013025\\\/Python-Break-Pass-Continue.jpg\",\"width\":1793,\"height\":1110},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.itpiran.net\\\/blog\\\/tutorials\\\/how-to-use-break-continue-and-pass-statements-when-working-with-loops-in-python-3-2\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.itpiran.net\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"\u0622\u0645\u0648\u0632\u0634\u06cc\",\"item\":\"https:\\\/\\\/www.itpiran.net\\\/blog\\\/category\\\/tutorials\\\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"\u0646\u062d\u0648\u0647 \u0627\u0633\u062a\u0641\u0627\u062f\u0647 \u0627\u0632 \u0639\u0628\u0627\u0631\u062a Continue\u060c Break \u0648 Pass \u0647\u0646\u06af\u0627\u0645 \u06a9\u0627\u0631 \u0628\u0627 \u062d\u0644\u0642\u0647 \u0647\u0627 \u062f\u0631 Python\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.itpiran.net\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/www.itpiran.net\\\/blog\\\/\",\"name\":\"\u0628\u0644\u0627\u06af ITPiran\",\"description\":\"\u0627\u062e\u0628\u0627\u0631 \u0648 \u0645\u0642\u0627\u0644\u0627\u062a \u062a\u062c\u0627\u0631\u062a \u067e\u0627\u06cc\u062f\u0627\u0631 \u0627\u06cc\u0631\u0627\u0646\u06cc\u0627\u0646\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.itpiran.net\\\/blog\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.itpiran.net\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.itpiran.net\\\/blog\\\/#organization\",\"name\":\"\u0628\u0644\u0627\u06af \u062a\u062c\u0627\u0631\u062a \u067e\u0627\u06cc\u062f\u0627\u0631 \u0627\u06cc\u0631\u0627\u0646\u06cc\u0627\u0646\",\"alternateName\":\"ITPIran Blog\",\"url\":\"https:\\\/\\\/www.itpiran.net\\\/blog\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\\\/\\\/www.itpiran.net\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/cdn.itpiran.net\\\/2023\\\/12\\\/27150508\\\/cropped-ITPIRAN-BLOG-LOGO-2.png\",\"contentUrl\":\"https:\\\/\\\/cdn.itpiran.net\\\/2023\\\/12\\\/27150508\\\/cropped-ITPIRAN-BLOG-LOGO-2.png\",\"width\":512,\"height\":512,\"caption\":\"\u0628\u0644\u0627\u06af \u062a\u062c\u0627\u0631\u062a \u067e\u0627\u06cc\u062f\u0627\u0631 \u0627\u06cc\u0631\u0627\u0646\u06cc\u0627\u0646\"},\"image\":{\"@id\":\"https:\\\/\\\/www.itpiran.net\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.itpiran.net\\\/blog\\\/#\\\/schema\\\/person\\\/04ed27b919baca468a2273f8e4318f81\",\"name\":\"admin\",\"url\":\"https:\\\/\\\/www.itpiran.net\\\/blog\\\/zh\\\/author\\\/admin\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"\u5982\u4f55\u5728 Python \u4e2d\u4f7f\u7528\u5faa\u73af\u65f6\u4f7f\u7528 Continue\u3001Break \u548c Pass \u8bed\u53e5 - ITPiran \u535a\u5ba2","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.itpiran.net\/blog\/zh\/tutorials\/how-to-use-break-continue-and-pass-statements-when-working-with-loops-in-python-3-2\/","og_locale":"zh_CN","og_type":"article","og_title":"\u0646\u062d\u0648\u0647 \u0627\u0633\u062a\u0641\u0627\u062f\u0647 \u0627\u0632 \u0639\u0628\u0627\u0631\u062a Continue\u060c Break \u0648 Pass \u0647\u0646\u06af\u0627\u0645 \u06a9\u0627\u0631 \u0628\u0627 \u062d\u0644\u0642\u0647 \u0647\u0627 \u062f\u0631 Python - \u0628\u0644\u0627\u06af ITPiran","og_description":"\u0645\u0642\u062f\u0645\u0647 \u0627\u0633\u062a\u0641\u0627\u062f\u0647 \u0627\u0632 \u062d\u0644\u0642\u0647\u200c\u0647\u0627\u06cc for \u0648 \u062d\u0644\u0642\u0647\u200c\u0647\u0627\u06cc while \u062f\u0631 \u067e\u0627\u06cc\u062a\u0648\u0646 \u0628\u0647 \u0634\u0645\u0627 \u0627\u0645\u06a9\u0627\u0646 \u0645\u06cc\u200c\u062f\u0647\u062f \u0648\u0638\u0627\u06cc\u0641 \u0631\u0627 \u062e\u0648\u062f\u06a9\u0627\u0631 \u0648&hellip;","og_url":"https:\/\/www.itpiran.net\/blog\/zh\/tutorials\/how-to-use-break-continue-and-pass-statements-when-working-with-loops-in-python-3-2\/","og_site_name":"\u0628\u0644\u0627\u06af ITPiran","article_published_time":"2024-12-18T22:01:53+00:00","og_image":[{"width":1793,"height":1110,"url":"https:\/\/cdn.itpiran.net\/2024\/12\/19013025\/Python-Break-Pass-Continue.jpg","type":"image\/jpeg"}],"author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"7 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.itpiran.net\/blog\/tutorials\/how-to-use-break-continue-and-pass-statements-when-working-with-loops-in-python-3-2\/#article","isPartOf":{"@id":"https:\/\/www.itpiran.net\/blog\/tutorials\/how-to-use-break-continue-and-pass-statements-when-working-with-loops-in-python-3-2\/"},"author":{"name":"admin","@id":"https:\/\/www.itpiran.net\/blog\/#\/schema\/person\/04ed27b919baca468a2273f8e4318f81"},"headline":"\u0646\u062d\u0648\u0647 \u0627\u0633\u062a\u0641\u0627\u062f\u0647 \u0627\u0632 \u0639\u0628\u0627\u0631\u062a Continue\u060c Break \u0648 Pass \u0647\u0646\u06af\u0627\u0645 \u06a9\u0627\u0631 \u0628\u0627 \u062d\u0644\u0642\u0647 \u0647\u0627 \u062f\u0631 Python","datePublished":"2024-12-18T22:01:53+00:00","mainEntityOfPage":{"@id":"https:\/\/www.itpiran.net\/blog\/tutorials\/how-to-use-break-continue-and-pass-statements-when-working-with-loops-in-python-3-2\/"},"wordCount":68,"commentCount":0,"publisher":{"@id":"https:\/\/www.itpiran.net\/blog\/#organization"},"image":{"@id":"https:\/\/www.itpiran.net\/blog\/tutorials\/how-to-use-break-continue-and-pass-statements-when-working-with-loops-in-python-3-2\/#primaryimage"},"thumbnailUrl":"https:\/\/cdn.itpiran.net\/2024\/12\/19013025\/Python-Break-Pass-Continue.jpg","keywords":["Python"],"articleSection":["\u0622\u0645\u0648\u0632\u0634\u06cc","\u0628\u0631\u0646\u0627\u0645\u0647 \u0646\u0648\u06cc\u0633\u06cc"],"inLanguage":"zh-Hans","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.itpiran.net\/blog\/tutorials\/how-to-use-break-continue-and-pass-statements-when-working-with-loops-in-python-3-2\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.itpiran.net\/blog\/tutorials\/how-to-use-break-continue-and-pass-statements-when-working-with-loops-in-python-3-2\/","url":"https:\/\/www.itpiran.net\/blog\/tutorials\/how-to-use-break-continue-and-pass-statements-when-working-with-loops-in-python-3-2\/","name":"\u5982\u4f55\u5728 Python \u4e2d\u4f7f\u7528\u5faa\u73af\u65f6\u4f7f\u7528 Continue\u3001Break \u548c Pass \u8bed\u53e5 - ITPiran \u535a\u5ba2","isPartOf":{"@id":"https:\/\/www.itpiran.net\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.itpiran.net\/blog\/tutorials\/how-to-use-break-continue-and-pass-statements-when-working-with-loops-in-python-3-2\/#primaryimage"},"image":{"@id":"https:\/\/www.itpiran.net\/blog\/tutorials\/how-to-use-break-continue-and-pass-statements-when-working-with-loops-in-python-3-2\/#primaryimage"},"thumbnailUrl":"https:\/\/cdn.itpiran.net\/2024\/12\/19013025\/Python-Break-Pass-Continue.jpg","datePublished":"2024-12-18T22:01:53+00:00","breadcrumb":{"@id":"https:\/\/www.itpiran.net\/blog\/tutorials\/how-to-use-break-continue-and-pass-statements-when-working-with-loops-in-python-3-2\/#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.itpiran.net\/blog\/tutorials\/how-to-use-break-continue-and-pass-statements-when-working-with-loops-in-python-3-2\/"]}]},{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.itpiran.net\/blog\/tutorials\/how-to-use-break-continue-and-pass-statements-when-working-with-loops-in-python-3-2\/#primaryimage","url":"https:\/\/cdn.itpiran.net\/2024\/12\/19013025\/Python-Break-Pass-Continue.jpg","contentUrl":"https:\/\/cdn.itpiran.net\/2024\/12\/19013025\/Python-Break-Pass-Continue.jpg","width":1793,"height":1110},{"@type":"BreadcrumbList","@id":"https:\/\/www.itpiran.net\/blog\/tutorials\/how-to-use-break-continue-and-pass-statements-when-working-with-loops-in-python-3-2\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.itpiran.net\/blog\/"},{"@type":"ListItem","position":2,"name":"\u0622\u0645\u0648\u0632\u0634\u06cc","item":"https:\/\/www.itpiran.net\/blog\/category\/tutorials\/"},{"@type":"ListItem","position":3,"name":"\u0646\u062d\u0648\u0647 \u0627\u0633\u062a\u0641\u0627\u062f\u0647 \u0627\u0632 \u0639\u0628\u0627\u0631\u062a Continue\u060c Break \u0648 Pass \u0647\u0646\u06af\u0627\u0645 \u06a9\u0627\u0631 \u0628\u0627 \u062d\u0644\u0642\u0647 \u0647\u0627 \u062f\u0631 Python"}]},{"@type":"WebSite","@id":"https:\/\/www.itpiran.net\/blog\/#website","url":"https:\/\/www.itpiran.net\/blog\/","name":"ITPiran\u535a\u5ba2","description":"\u4f0a\u6717\u53ef\u6301\u7eed\u8d38\u6613\u65b0\u95fb\u548c\u6587\u7ae0","publisher":{"@id":"https:\/\/www.itpiran.net\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.itpiran.net\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"zh-Hans"},{"@type":"Organization","@id":"https:\/\/www.itpiran.net\/blog\/#organization","name":"\u4f0a\u6717\u53ef\u6301\u7eed\u5546\u4e1a\u535a\u5ba2","alternateName":"ITPIran Blog","url":"https:\/\/www.itpiran.net\/blog\/","logo":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.itpiran.net\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/cdn.itpiran.net\/2023\/12\/27150508\/cropped-ITPIRAN-BLOG-LOGO-2.png","contentUrl":"https:\/\/cdn.itpiran.net\/2023\/12\/27150508\/cropped-ITPIRAN-BLOG-LOGO-2.png","width":512,"height":512,"caption":"\u0628\u0644\u0627\u06af \u062a\u062c\u0627\u0631\u062a \u067e\u0627\u06cc\u062f\u0627\u0631 \u0627\u06cc\u0631\u0627\u0646\u06cc\u0627\u0646"},"image":{"@id":"https:\/\/www.itpiran.net\/blog\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/www.itpiran.net\/blog\/#\/schema\/person\/04ed27b919baca468a2273f8e4318f81","name":"\u884c\u653f","url":"https:\/\/www.itpiran.net\/blog\/zh\/author\/admin\/"}]}},"_links":{"self":[{"href":"https:\/\/www.itpiran.net\/blog\/zh\/wp-json\/wp\/v2\/posts\/16539","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.itpiran.net\/blog\/zh\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.itpiran.net\/blog\/zh\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.itpiran.net\/blog\/zh\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.itpiran.net\/blog\/zh\/wp-json\/wp\/v2\/comments?post=16539"}],"version-history":[{"count":1,"href":"https:\/\/www.itpiran.net\/blog\/zh\/wp-json\/wp\/v2\/posts\/16539\/revisions"}],"predecessor-version":[{"id":16543,"href":"https:\/\/www.itpiran.net\/blog\/zh\/wp-json\/wp\/v2\/posts\/16539\/revisions\/16543"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.itpiran.net\/blog\/zh\/wp-json\/wp\/v2\/media\/16542"}],"wp:attachment":[{"href":"https:\/\/www.itpiran.net\/blog\/zh\/wp-json\/wp\/v2\/media?parent=16539"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.itpiran.net\/blog\/zh\/wp-json\/wp\/v2\/categories?post=16539"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.itpiran.net\/blog\/zh\/wp-json\/wp\/v2\/tags?post=16539"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}