{"id":32,"date":"2024-08-13T11:51:32","date_gmt":"2024-08-13T03:51:32","guid":{"rendered":"http:\/\/8.134.236.44\/wordpress\/?p=32"},"modified":"2024-08-13T11:51:32","modified_gmt":"2024-08-13T03:51:32","slug":"%e6%a0%87%e5%87%86%e8%be%93%e5%85%a5%e8%be%93%e5%87%ba%e5%8f%8a-io-%e6%93%8d%e4%bd%9c","status":"publish","type":"post","link":"https:\/\/rrt01.cn\/?p=32","title":{"rendered":"\u6807\u51c6\u8f93\u5165\u8f93\u51fa\u53ca IO \u64cd\u4f5c"},"content":{"rendered":"\n<p><div id=\"ez-toc-container\" class=\"ez-toc-v2_0_68_1 counter-hierarchy ez-toc-counter ez-toc-grey ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title \" >Table of Contents<\/p>\n<span class=\"ez-toc-title-toggle\"><a href=\"#\" class=\"ez-toc-pull-right ez-toc-btn ez-toc-btn-xs ez-toc-btn-default ez-toc-toggle\" aria-label=\"Toggle Table of Content\"><span class=\"ez-toc-js-icon-con\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/span><\/a><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/rrt01.cn\/?p=32\/#1_%E5%A4%9A%E7%9B%AE%E6%A0%87%E8%B5%8B%E5%80%BC\" title=\"1. \u591a\u76ee\u6807\u8d4b\u503c\">1. \u591a\u76ee\u6807\u8d4b\u503c<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/rrt01.cn\/?p=32\/#2_%E5%9F%BA%E6%9C%AC%E8%BE%93%E5%85%A5%E8%BE%93%E5%87%BA\" title=\"2. \u57fa\u672c\u8f93\u5165\u8f93\u51fa\">2. \u57fa\u672c\u8f93\u5165\u8f93\u51fa<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/rrt01.cn\/?p=32\/#3_%E7%A8%8B%E5%BA%8F%E6%8E%A7%E5%88%B6%E7%BB%93%E6%9E%84\" title=\"3. \u7a0b\u5e8f\u63a7\u5236\u7ed3\u6784\">3. \u7a0b\u5e8f\u63a7\u5236\u7ed3\u6784<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/rrt01.cn\/?p=32\/#4_%E5%8F%AF%E6%89%A7%E8%A1%8C%E5%AF%B9%E8%B1%A1%E8%A7%A3%E6%9E%90%E5%91%BD%E4%BB%A4\" title=\"4. \u53ef\u6267\u884c\u5bf9\u8c61\u89e3\u6790\u547d\u4ee4\">4. \u53ef\u6267\u884c\u5bf9\u8c61\u89e3\u6790\u547d\u4ee4<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/rrt01.cn\/?p=32\/#5_IO_%E6%93%8D%E4%BD%9C\" title=\"5. IO \u64cd\u4f5c\">5. IO \u64cd\u4f5c<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/rrt01.cn\/?p=32\/#1_%E6%89%93%E5%BC%80%E6%96%87%E4%BB%B6\" title=\"(1) \u6253\u5f00\u6587\u4ef6\">(1) \u6253\u5f00\u6587\u4ef6<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/rrt01.cn\/?p=32\/#2_%E6%89%93%E5%BC%80%E6%A8%A1%E5%BC%8F\" title=\"(2) \u6253\u5f00\u6a21\u5f0f\">(2) \u6253\u5f00\u6a21\u5f0f<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-8\" href=\"https:\/\/rrt01.cn\/?p=32\/#3_%E6%96%87%E4%BB%B6%E8%AF%BB%E5%8F%96\" title=\"(3) \u6587\u4ef6\u8bfb\u53d6\">(3) \u6587\u4ef6\u8bfb\u53d6<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-9\" href=\"https:\/\/rrt01.cn\/?p=32\/#4_%E5%86%99%E5%85%A5%E6%95%B0%E6%8D%AE\" title=\"(4) \u5199\u5165\u6570\u636e\">(4) \u5199\u5165\u6570\u636e<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-10\" href=\"https:\/\/rrt01.cn\/?p=32\/#5_SIO_%E6%93%8D%E4%BD%9C\" title=\"(5) SIO \u64cd\u4f5c\">(5) SIO \u64cd\u4f5c<\/a><\/li><\/ul><\/li><\/ul><\/nav><\/div>\n<h2 cid=\"n85\" mdtype=\"heading\" class=\"md-end-block md-heading\" style=\"box-sizing: border-box; break-after: avoid-page; break-inside: avoid; orphans: 4; font-size: 1.63rem; margin: 0px 0px 1.5rem; font-family: &quot;Lucida Grande&quot;, Corbel, sans-serif; clear: both; overflow-wrap: break-word; padding: 0px; color: rgb(222, 222, 222); line-height: 1.875rem; letter-spacing: -1px; position: relative;\"><span class=\"ez-toc-section\" id=\"1_%E5%A4%9A%E7%9B%AE%E6%A0%87%E8%B5%8B%E5%80%BC\"><\/span><span md-inline=\"plain\" class=\"md-plain\" style=\"box-sizing: border-box;\">1. \u591a\u76ee\u6807\u8d4b\u503c<\/span><span class=\"ez-toc-section-end\"><\/span><\/h2><pre class=\"md-fences md-end-block ty-contain-cm modeLoaded\" spellcheck=\"false\" lang=\"python\" cid=\"n86\" mdtype=\"fences\" style=\"box-sizing: border-box; overflow: visible; font-family: Monaco, Consolas, &quot;Andale Mono&quot;, &quot;DejaVu Sans Mono&quot;, monospace; margin-top: 0px; margin-bottom: 20px; font-size: 0.9rem; break-inside: avoid; white-space: normal; background: rgb(51, 51, 51); padding: 10px 10px 10px 30px; width: inherit; color: rgb(184, 191, 198); position: relative !important;\"><span role=\"presentation\" style=\"box-sizing: border-box; padding-right: 0.1px;\"><span class=\"cm-variable\" style=\"box-sizing: border-box;\">a<\/span>,<span class=\"cm-variable\" style=\"box-sizing: border-box;\">b<\/span>,<span class=\"cm-variable\" style=\"box-sizing: border-box;\">c<\/span>,<span class=\"cm-variable\" style=\"box-sizing: border-box;\">d<\/span>,<span class=\"cm-variable\" style=\"box-sizing: border-box;\">e<\/span> = <span class=\"cm-string\" style=\"box-sizing: border-box; color: rgb(210, 107, 107);\">'\u6211\u559c\u6b22\u4f60\u554a'<\/span><\/span><span role=\"presentation\" style=\"box-sizing: border-box; padding-right: 0.1px;\"><span cm-text=\"\" cm-zwsp=\"\" style=\"box-sizing: border-box;\">\u200b<\/span><\/span><span role=\"presentation\" style=\"box-sizing: border-box; padding-right: 0.1px;\"><span class=\"cm-variable\" style=\"box-sizing: border-box;\">a<\/span>, <span class=\"cm-operator\" style=\"box-sizing: border-box;\">*<\/span><span class=\"cm-variable\" style=\"box-sizing: border-box;\">b<\/span> = <span class=\"cm-string\" style=\"box-sizing: border-box; color: rgb(210, 107, 107);\">'\u6211\u559c\u6b22\u4f60\u554a'<\/span><\/span><span role=\"presentation\" style=\"box-sizing: border-box; padding-right: 0.1px;\"><span class=\"cm-operator\" style=\"box-sizing: border-box;\">>>><\/span> <span class=\"cm-variable\" style=\"box-sizing: border-box;\">a<\/span> = <span class=\"cm-string\" style=\"box-sizing: border-box; color: rgb(210, 107, 107);\">'\u6211'<\/span>, <span class=\"cm-variable\" style=\"box-sizing: border-box;\">b<\/span> = <span class=\"cm-string\" style=\"box-sizing: border-box; color: rgb(210, 107, 107);\">'\u559c\u6b22\u4f60\u554a'<\/span><\/span><span role=\"presentation\" style=\"box-sizing: border-box; padding-right: 0.1px;\"><span cm-text=\"\" cm-zwsp=\"\" style=\"box-sizing: border-box;\">\u200b<\/span><\/span><span role=\"presentation\" style=\"box-sizing: border-box; padding-right: 0.1px;\"><span class=\"cm-variable\" style=\"box-sizing: border-box;\">a<\/span> = <span class=\"cm-variable\" style=\"box-sizing: border-box;\">b<\/span> = <span class=\"cm-variable\" style=\"box-sizing: border-box;\">c<\/span> = <span class=\"cm-variable\" style=\"box-sizing: border-box;\">d<\/span> = <span class=\"cm-variable\" style=\"box-sizing: border-box;\">e<\/span> = <span class=\"cm-number\" style=\"box-sizing: border-box; color: rgb(100, 171, 143);\">1<\/span><span class=\"cm-tab\" role=\"presentation\" cm-text=\"\t\" style=\"box-sizing: border-box; font-family: var(--monospace); position: relative; display: inline-block;\">   <\/span><span class=\"cm-comment\" style=\"box-sizing: border-box; color: rgb(218, 146, 74);\"># \u5168\u90e8\u8d4b\u503c\u4e3a 1 , \u4e14\u5730\u5740\u4e0d\u540c<\/span><\/span><span role=\"presentation\" style=\"box-sizing: border-box; padding-right: 0.1px;\"><span cm-text=\"\" cm-zwsp=\"\" style=\"box-sizing: border-box;\">\u200b<\/span><\/span><span role=\"presentation\" style=\"box-sizing: border-box; padding-right: 0.1px;\"><span class=\"cm-variable\" style=\"box-sizing: border-box;\">a<\/span>,<span class=\"cm-variable\" style=\"box-sizing: border-box;\">b<\/span> = <span class=\"cm-variable\" style=\"box-sizing: border-box;\">b<\/span>,<span class=\"cm-variable\" style=\"box-sizing: border-box;\">a<\/span><span class=\"cm-tab\" role=\"presentation\" cm-text=\"\t\" style=\"box-sizing: border-box; font-family: var(--monospace); position: relative; display: inline-block;\">   <\/span><span class=\"cm-comment\" style=\"box-sizing: border-box; color: rgb(218, 146, 74);\"># \u4ea4\u6362\u503c<\/span><\/span><\/pre><h2 cid=\"n87\" mdtype=\"heading\" class=\"md-end-block md-heading\" style=\"box-sizing: border-box; break-after: avoid-page; break-inside: avoid; orphans: 4; font-size: 1.63rem; margin: 0px 0px 1.5rem; font-family: &quot;Lucida Grande&quot;, Corbel, sans-serif; clear: both; overflow-wrap: break-word; padding: 0px; color: rgb(222, 222, 222); line-height: 1.875rem; letter-spacing: -1px; position: relative;\"><span class=\"ez-toc-section\" id=\"2_%E5%9F%BA%E6%9C%AC%E8%BE%93%E5%85%A5%E8%BE%93%E5%87%BA\"><\/span><span md-inline=\"plain\" class=\"md-plain\" style=\"box-sizing: border-box;\">2. \u57fa\u672c\u8f93\u5165\u8f93\u51fa<\/span><span class=\"ez-toc-section-end\"><\/span><\/h2><pre class=\"md-fences md-end-block ty-contain-cm modeLoaded\" spellcheck=\"false\" lang=\"python\" cid=\"n88\" mdtype=\"fences\" style=\"box-sizing: border-box; overflow: visible; font-family: Monaco, Consolas, &quot;Andale Mono&quot;, &quot;DejaVu Sans Mono&quot;, monospace; margin-top: 0px; margin-bottom: 20px; font-size: 0.9rem; break-inside: avoid; white-space: normal; background: rgb(51, 51, 51); padding: 10px 10px 10px 30px; width: inherit; color: rgb(184, 191, 198); position: relative !important;\"><span role=\"presentation\" style=\"box-sizing: border-box; padding-right: 0.1px;\"><span class=\"cm-builtin\" style=\"box-sizing: border-box; color: rgb(243, 179, 248);\">print<\/span>(<span class=\"cm-variable\" style=\"box-sizing: border-box;\">value1<\/span>, <span class=\"cm-variable\" style=\"box-sizing: border-box;\">value2<\/span>, ..., <span class=\"cm-variable\" style=\"box-sizing: border-box;\">sep<\/span>=<span class=\"cm-string\" style=\"box-sizing: border-box; color: rgb(210, 107, 107);\">' '<\/span>, <span class=\"cm-variable\" style=\"box-sizing: border-box;\">file<\/span>=<span class=\"cm-variable\" style=\"box-sizing: border-box;\">sys<\/span>.<span class=\"cm-property\" style=\"box-sizing: border-box;\">stdout<\/span>, <span class=\"cm-variable\" style=\"box-sizing: border-box;\">end<\/span>=<span class=\"cm-string\" style=\"box-sizing: border-box; color: rgb(210, 107, 107);\">'\\n'<\/span>)<\/span><span role=\"presentation\" style=\"box-sizing: border-box; padding-right: 0.1px;\"><span class=\"cm-comment\" style=\"box-sizing: border-box; color: rgb(218, 146, 74);\"># sep \u5206\u9694\u7b26, \u9ed8\u8ba4\u4e3a\u7a7a\u683c<\/span><\/span><span role=\"presentation\" style=\"box-sizing: border-box; padding-right: 0.1px;\"><span class=\"cm-comment\" style=\"box-sizing: border-box; color: rgb(218, 146, 74);\"># file \u8f93\u51fa\u4f4d\u7f6e, \u9ed8\u8ba4\u4e3a\u63a7\u5236\u53f0, \u4e5f\u53ef\u4ee5\u91cd\u5b9a\u5411\u5230\u6587\u4ef6<\/span><\/span><span role=\"presentation\" style=\"box-sizing: border-box; padding-right: 0.1px;\"><span class=\"cm-comment\" style=\"box-sizing: border-box; color: rgb(218, 146, 74);\"># end \u7ed3\u5c3e\u6dfb\u52a0\u5185\u5bb9, \u9ed8\u8ba4\u6362\u884c<\/span><\/span><span role=\"presentation\" style=\"box-sizing: border-box; padding-right: 0.1px;\"><span cm-text=\"\" cm-zwsp=\"\" style=\"box-sizing: border-box;\">\u200b<\/span><\/span><span role=\"presentation\" style=\"box-sizing: border-box; padding-right: 0.1px;\"><span class=\"cm-builtin\" style=\"box-sizing: border-box; color: rgb(243, 179, 248);\">input<\/span>(<span class=\"cm-variable\" style=\"box-sizing: border-box;\">string<\/span>)<\/span><span role=\"presentation\" style=\"box-sizing: border-box; padding-right: 0.1px;\"><span class=\"cm-comment\" style=\"box-sizing: border-box; color: rgb(218, 146, 74);\"># \u4ee5 string \u4f5c\u4e3a\u63d0\u793a\u7b26, \u8bf7\u6c42\u7528\u6237\u8f93\u5165<\/span><\/span><span role=\"presentation\" style=\"box-sizing: border-box; padding-right: 0.1px;\"><span class=\"cm-comment\" style=\"box-sizing: border-box; color: rgb(218, 146, 74);\"># \u8fd4\u56de\u5b57\u7b26\u4e32, \u5e38\u7ed3\u5408 exec, eval, int, float \u7b49\u4f7f\u7528<\/span><\/span><\/pre><h2 cid=\"n89\" mdtype=\"heading\" class=\"md-end-block md-heading\" style=\"box-sizing: border-box; break-after: avoid-page; break-inside: avoid; orphans: 4; font-size: 1.63rem; margin: 0px 0px 1.5rem; font-family: &quot;Lucida Grande&quot;, Corbel, sans-serif; clear: both; overflow-wrap: break-word; padding: 0px; color: rgb(222, 222, 222); line-height: 1.875rem; letter-spacing: -1px; position: relative;\"><span class=\"ez-toc-section\" id=\"3_%E7%A8%8B%E5%BA%8F%E6%8E%A7%E5%88%B6%E7%BB%93%E6%9E%84\"><\/span><span md-inline=\"plain\" class=\"md-plain\" style=\"box-sizing: border-box;\">3. \u7a0b\u5e8f\u63a7\u5236\u7ed3\u6784<\/span><span class=\"ez-toc-section-end\"><\/span><\/h2><p cid=\"n90\" mdtype=\"paragraph\" class=\"md-end-block md-p\" style=\"box-sizing: border-box; line-height: inherit; orphans: 4; margin-top: 0px; margin-bottom: 1.5rem; overflow-wrap: break-word; position: relative; color: rgb(184, 191, 198); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, &quot;Segoe UI Emoji&quot;, sans-serif; font-size: 16px;\"><span md-inline=\"code\" spellcheck=\"false\" class=\"md-pair-s\" style=\"box-sizing: border-box;\"><code style=\"box-sizing: border-box; font-family: Monaco, Consolas, &quot;Andale Mono&quot;, &quot;DejaVu Sans Mono&quot;, monospace; vertical-align: initial; font-size: 0.875em; background: rgba(0, 0, 0, 0.05); padding: 2px 5px;\">if-elif-else<\/code><\/span><span md-inline=\"plain\" class=\"md-plain\" style=\"box-sizing: border-box;\"> \u8bed\u53e5, \u7528\u4e8e\u591a\u5206\u652f\u9009\u62e9, \u8fd9\u91cc\u7684 \u201c\u8868\u8fbe\u5f0f\u201d \u53ef\u4ee5\u662f\u5e8f\u5217\u5bf9\u8c61, \u6b64\u65f6\u5224\u65ad\u5e8f\u5217\u5bf9\u8c61\u662f\u5426\u975e\u7a7a, else \u548c elif \u4e0d\u662f\u5fc5\u8981\u7684<\/span><\/p><pre class=\"md-fences md-end-block ty-contain-cm modeLoaded\" spellcheck=\"false\" lang=\"python\" cid=\"n91\" mdtype=\"fences\" style=\"box-sizing: border-box; overflow: visible; font-family: Monaco, Consolas, &quot;Andale Mono&quot;, &quot;DejaVu Sans Mono&quot;, monospace; margin-top: 0px; margin-bottom: 20px; font-size: 0.9rem; break-inside: avoid; white-space: normal; background: rgb(51, 51, 51); padding: 10px 10px 10px 30px; width: inherit; color: rgb(184, 191, 198); position: relative !important;\"><span role=\"presentation\" style=\"box-sizing: border-box; padding-right: 0.1px;\"><span class=\"cm-keyword\" style=\"box-sizing: border-box; color: rgb(200, 143, 208);\">if<\/span> <span class=\"cm-variable\" style=\"box-sizing: border-box;\">\u8868\u8fbe\u5f0f1<\/span>:<\/span><span role=\"presentation\" style=\"box-sizing: border-box; padding-right: 0.1px;\"><span class=\"cm-tab\" role=\"presentation\" cm-text=\"\t\" style=\"box-sizing: border-box; font-family: var(--monospace); position: relative; display: inline-block;\">    <\/span><span class=\"cm-variable\" style=\"box-sizing: border-box;\">\u8bed\u53e5<\/span><\/span><span role=\"presentation\" style=\"box-sizing: border-box; padding-right: 0.1px;\"><span class=\"cm-keyword\" style=\"box-sizing: border-box; color: rgb(200, 143, 208);\">elif<\/span> <span class=\"cm-variable\" style=\"box-sizing: border-box;\">\u8868\u8fbe\u5f0f2<\/span>:<\/span><span role=\"presentation\" style=\"box-sizing: border-box; padding-right: 0.1px;\"><span class=\"cm-tab\" role=\"presentation\" cm-text=\"\t\" style=\"box-sizing: border-box; font-family: var(--monospace); position: relative; display: inline-block;\">    <\/span><span class=\"cm-variable\" style=\"box-sizing: border-box;\">\u8bed\u53e5<\/span><\/span><span role=\"presentation\" style=\"box-sizing: border-box; padding-right: 0.1px;\"><span class=\"cm-keyword\" style=\"box-sizing: border-box; color: rgb(200, 143, 208);\">elif<\/span> <span class=\"cm-variable\" style=\"box-sizing: border-box;\">\u8868\u8fbe\u5f0f3<\/span>:<\/span><span role=\"presentation\" style=\"box-sizing: border-box; padding-right: 0.1px;\"> \u00a0 \u00a0<span class=\"cm-variable\" style=\"box-sizing: border-box;\">\u8bed\u53e5<\/span><\/span><span role=\"presentation\" style=\"box-sizing: border-box; padding-right: 0.1px;\">...<\/span><span role=\"presentation\" style=\"box-sizing: border-box; padding-right: 0.1px;\"><span class=\"cm-property\" style=\"box-sizing: border-box;\">else<\/span>:<\/span><span role=\"presentation\" style=\"box-sizing: border-box; padding-right: 0.1px;\"> \u00a0 \u00a0<span class=\"cm-variable\" style=\"box-sizing: border-box;\">\u8bed\u53e5<\/span><\/span><\/pre><p cid=\"n92\" mdtype=\"paragraph\" class=\"md-end-block md-p\" style=\"box-sizing: border-box; line-height: inherit; orphans: 4; margin-top: 0px; margin-bottom: 1.5rem; overflow-wrap: break-word; position: relative; color: rgb(184, 191, 198); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, &quot;Segoe UI Emoji&quot;, sans-serif; font-size: 16px;\"><span md-inline=\"code\" spellcheck=\"false\" class=\"md-pair-s\" style=\"box-sizing: border-box;\"><code style=\"box-sizing: border-box; font-family: Monaco, Consolas, &quot;Andale Mono&quot;, &quot;DejaVu Sans Mono&quot;, monospace; vertical-align: initial; font-size: 0.875em; background: rgba(0, 0, 0, 0.05); padding: 2px 5px;\">for (i, j, ...) in iterable<\/code><\/span><span md-inline=\"plain\" class=\"md-plain\" style=\"box-sizing: border-box;\">\u8bed\u53e5, \u7528\u4e8e\u5faa\u73af, \u53ef\u4ee5\u4f7f\u7528 <\/span><span md-inline=\"code\" spellcheck=\"false\" class=\"md-pair-s\" style=\"box-sizing: border-box;\"><code style=\"box-sizing: border-box; font-family: Monaco, Consolas, &quot;Andale Mono&quot;, &quot;DejaVu Sans Mono&quot;, monospace; vertical-align: initial; font-size: 0.875em; background: rgba(0, 0, 0, 0.05); padding: 2px 5px;\">countine<\/code><\/span><span md-inline=\"plain\" class=\"md-plain\" style=\"box-sizing: border-box;\"> \u548c <\/span><span md-inline=\"code\" spellcheck=\"false\" class=\"md-pair-s\" style=\"box-sizing: border-box;\"><code style=\"box-sizing: border-box; font-family: Monaco, Consolas, &quot;Andale Mono&quot;, &quot;DejaVu Sans Mono&quot;, monospace; vertical-align: initial; font-size: 0.875em; background: rgba(0, 0, 0, 0.05); padding: 2px 5px;\">break<\/code><\/span><span md-inline=\"plain\" class=\"md-plain\" style=\"box-sizing: border-box;\"> \u8fdb\u884c\u8bed\u53e5\u63a7\u5236<\/span><\/p><pre class=\"md-fences md-end-block ty-contain-cm modeLoaded\" spellcheck=\"false\" lang=\"python\" cid=\"n93\" mdtype=\"fences\" style=\"box-sizing: border-box; overflow: visible; font-family: Monaco, Consolas, &quot;Andale Mono&quot;, &quot;DejaVu Sans Mono&quot;, monospace; margin-top: 0px; margin-bottom: 20px; font-size: 0.9rem; break-inside: avoid; white-space: normal; background: rgb(51, 51, 51); padding: 10px 10px 10px 30px; width: inherit; color: rgb(184, 191, 198); position: relative !important;\"><span role=\"presentation\" style=\"box-sizing: border-box; padding-right: 0.1px;\"><span class=\"cm-keyword\" style=\"box-sizing: border-box; color: rgb(200, 143, 208);\">for<\/span> <span class=\"cm-variable\" style=\"box-sizing: border-box;\">i<\/span> <span class=\"cm-keyword\" style=\"box-sizing: border-box; color: rgb(200, 143, 208);\">in<\/span> <span class=\"cm-variable\" style=\"box-sizing: border-box;\">iterable<\/span>:<\/span><span role=\"presentation\" style=\"box-sizing: border-box; padding-right: 0.1px;\"><span class=\"cm-tab\" role=\"presentation\" cm-text=\"\t\" style=\"box-sizing: border-box; font-family: var(--monospace); position: relative; display: inline-block;\">    <\/span><span class=\"cm-variable\" style=\"box-sizing: border-box;\">\u8bed\u53e5<\/span><\/span><span role=\"presentation\" style=\"box-sizing: border-box; padding-right: 0.1px;\"><span cm-text=\"\" cm-zwsp=\"\" style=\"box-sizing: border-box;\">\u200b<\/span><\/span><span role=\"presentation\" style=\"box-sizing: border-box; padding-right: 0.1px;\"><span class=\"cm-keyword\" style=\"box-sizing: border-box; color: rgb(200, 143, 208);\">for<\/span> <span class=\"cm-variable\" style=\"box-sizing: border-box;\">i<\/span>,<span class=\"cm-variable\" style=\"box-sizing: border-box;\">j<\/span> <span class=\"cm-keyword\" style=\"box-sizing: border-box; color: rgb(200, 143, 208);\">in<\/span> <span class=\"cm-variable\" style=\"box-sizing: border-box;\">iterable<\/span>:<span class=\"cm-tab\" role=\"presentation\" cm-text=\"\t\" style=\"box-sizing: border-box; font-family: var(--monospace); position: relative; display: inline-block;\">    <\/span><span class=\"cm-comment\" style=\"box-sizing: border-box; color: rgb(218, 146, 74);\"># \u53ef\u4ee5\u540c\u65f6\u4f7f\u7528\u591a\u4e2a \u201c\u8ba1\u6570\u5668\u201d<\/span><\/span><span role=\"presentation\" style=\"box-sizing: border-box; padding-right: 0.1px;\"><span class=\"cm-tab\" role=\"presentation\" cm-text=\"\t\" style=\"box-sizing: border-box; font-family: var(--monospace); position: relative; display: inline-block;\">    <\/span><span class=\"cm-variable\" style=\"box-sizing: border-box;\">\u8bed\u53e5<\/span><\/span><\/pre><p cid=\"n94\" mdtype=\"paragraph\" class=\"md-end-block md-p\" style=\"box-sizing: border-box; line-height: inherit; orphans: 4; margin-top: 0px; margin-bottom: 1.5rem; overflow-wrap: break-word; position: relative; color: rgb(184, 191, 198); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, &quot;Segoe UI Emoji&quot;, sans-serif; font-size: 16px;\"><span md-inline=\"code\" spellcheck=\"false\" class=\"md-pair-s\" style=\"box-sizing: border-box;\"><code style=\"box-sizing: border-box; font-family: Monaco, Consolas, &quot;Andale Mono&quot;, &quot;DejaVu Sans Mono&quot;, monospace; vertical-align: initial; font-size: 0.875em; background: rgba(0, 0, 0, 0.05); padding: 2px 5px;\">while<\/code><\/span><span md-inline=\"plain\" class=\"md-plain\" style=\"box-sizing: border-box;\"> \u8bed\u53e5, \u7528\u4e8e\u5faa\u73af, \u53ef\u4ee5\u4f7f\u7528 <\/span><span md-inline=\"code\" spellcheck=\"false\" class=\"md-pair-s\" style=\"box-sizing: border-box;\"><code style=\"box-sizing: border-box; font-family: Monaco, Consolas, &quot;Andale Mono&quot;, &quot;DejaVu Sans Mono&quot;, monospace; vertical-align: initial; font-size: 0.875em; background: rgba(0, 0, 0, 0.05); padding: 2px 5px;\">countine<\/code><\/span><span md-inline=\"plain\" class=\"md-plain\" style=\"box-sizing: border-box;\"> (\u7ed3\u675f\u672c\u6b21\u5faa\u73af)\u548c <\/span><span md-inline=\"code\" spellcheck=\"false\" class=\"md-pair-s\" style=\"box-sizing: border-box;\"><code style=\"box-sizing: border-box; font-family: Monaco, Consolas, &quot;Andale Mono&quot;, &quot;DejaVu Sans Mono&quot;, monospace; vertical-align: initial; font-size: 0.875em; background: rgba(0, 0, 0, 0.05); padding: 2px 5px;\">break<\/code><\/span><span md-inline=\"plain\" class=\"md-plain\" style=\"box-sizing: border-box;\"> (\u7ed3\u675f\u6b64\u5faa\u73af\u8bed\u53e5)\u8fdb\u884c\u8bed\u53e5\u63a7\u5236, else \u4e0d\u662f\u5fc5\u8981\u7684<\/span><\/p><pre class=\"md-fences md-end-block ty-contain-cm modeLoaded\" spellcheck=\"false\" lang=\"python\" cid=\"n95\" mdtype=\"fences\" style=\"box-sizing: border-box; overflow: visible; font-family: Monaco, Consolas, &quot;Andale Mono&quot;, &quot;DejaVu Sans Mono&quot;, monospace; margin-top: 0px; margin-bottom: 20px; font-size: 0.9rem; break-inside: avoid; white-space: normal; background: rgb(51, 51, 51); padding: 10px 10px 10px 30px; width: inherit; color: rgb(184, 191, 198); position: relative !important;\"><span role=\"presentation\" style=\"box-sizing: border-box; padding-right: 0.1px;\"><span class=\"cm-keyword\" style=\"box-sizing: border-box; color: rgb(200, 143, 208);\">while<\/span> <span class=\"cm-variable\" style=\"box-sizing: border-box;\">\u8868\u8fbe\u5f0f<\/span>: <\/span><span role=\"presentation\" style=\"box-sizing: border-box; padding-right: 0.1px;\"><span class=\"cm-tab\" role=\"presentation\" cm-text=\"\t\" style=\"box-sizing: border-box; font-family: var(--monospace); position: relative; display: inline-block;\">    <\/span><span class=\"cm-variable\" style=\"box-sizing: border-box;\">\u8bed\u53e5<\/span><\/span><span role=\"presentation\" style=\"box-sizing: border-box; padding-right: 0.1px;\"><span class=\"cm-keyword\" style=\"box-sizing: border-box; color: rgb(200, 143, 208);\">else<\/span>:<\/span><span role=\"presentation\" style=\"box-sizing: border-box; padding-right: 0.1px;\"> \u00a0 \u00a0<span class=\"cm-variable\" style=\"box-sizing: border-box;\">\u8bed\u53e5<\/span><\/span><\/pre><p cid=\"n96\" mdtype=\"paragraph\" class=\"md-end-block md-p\" style=\"box-sizing: border-box; line-height: inherit; orphans: 4; margin-top: 0px; margin-bottom: 1.5rem; overflow-wrap: break-word; position: relative; color: rgb(184, 191, 198); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, &quot;Segoe UI Emoji&quot;, sans-serif; font-size: 16px;\"><span md-inline=\"code\" spellcheck=\"false\" class=\"md-pair-s\" style=\"box-sizing: border-box;\"><code style=\"box-sizing: border-box; font-family: Monaco, Consolas, &quot;Andale Mono&quot;, &quot;DejaVu Sans Mono&quot;, monospace; vertical-align: initial; font-size: 0.875em; background: rgba(0, 0, 0, 0.05); padding: 2px 5px;\">try<\/code><\/span><span md-inline=\"plain\" class=\"md-plain\" style=\"box-sizing: border-box;\"> \u8bed\u53e5, \u7528\u4e8e\u6355\u6349\u5f02\u5e38, \u4ece\u4e0a\u5230\u4e0b, \u82e5\u672a\u88ab\u6355\u6349, \u5219\u8fdb\u5165 else, finally \u662f\u4e00\u5b9a\u4f1a\u6267\u884c\u7684\u8bed\u53e5, \u76f8\u5f53\u4e8e\u544a\u8bc9\u201c\u6211\u5df2\u7ecf\u5904\u7406\u5b8c\u6240\u6709\u7684\u9519\u8bef\u4e86\u201d<\/span><\/p><pre class=\"md-fences md-end-block ty-contain-cm modeLoaded\" spellcheck=\"false\" lang=\"python\" cid=\"n97\" mdtype=\"fences\" style=\"box-sizing: border-box; overflow: visible; font-family: Monaco, Consolas, &quot;Andale Mono&quot;, &quot;DejaVu Sans Mono&quot;, monospace; margin-top: 0px; margin-bottom: 20px; font-size: 0.9rem; break-inside: avoid; white-space: normal; background: rgb(51, 51, 51); padding: 10px 10px 10px 30px; width: inherit; color: rgb(184, 191, 198); position: relative !important;\"><span role=\"presentation\" style=\"box-sizing: border-box; padding-right: 0.1px;\"><span class=\"cm-keyword\" style=\"box-sizing: border-box; color: rgb(200, 143, 208);\">try<\/span>:<\/span><span role=\"presentation\" style=\"box-sizing: border-box; padding-right: 0.1px;\"><span class=\"cm-tab\" role=\"presentation\" cm-text=\"\t\" style=\"box-sizing: border-box; font-family: var(--monospace); position: relative; display: inline-block;\">    <\/span><span class=\"cm-variable\" style=\"box-sizing: border-box;\">\u8bed\u53e5<\/span><span class=\"cm-tab\" role=\"presentation\" cm-text=\"\t\" style=\"box-sizing: border-box; font-family: var(--monospace); position: relative; display: inline-block;\">  <\/span><span class=\"cm-comment\" style=\"box-sizing: border-box; color: rgb(218, 146, 74);\"># \u4e00\u822c\u53ea\u5199\u4e00\u6761\u8bed\u53e5<\/span><\/span><span role=\"presentation\" style=\"box-sizing: border-box; padding-right: 0.1px;\"><span class=\"cm-keyword\" style=\"box-sizing: border-box; color: rgb(200, 143, 208);\">except<\/span> <span class=\"cm-variable\" style=\"box-sizing: border-box;\">\u5f02\u5e38\u7c7b1<\/span>:<\/span><span role=\"presentation\" style=\"box-sizing: border-box; padding-right: 0.1px;\"> \u00a0 \u00a0<span class=\"cm-variable\" style=\"box-sizing: border-box;\">\u8bed\u53e5<\/span><\/span><span role=\"presentation\" style=\"box-sizing: border-box; padding-right: 0.1px;\"><span class=\"cm-keyword\" style=\"box-sizing: border-box; color: rgb(200, 143, 208);\">except<\/span> <span class=\"cm-variable\" style=\"box-sizing: border-box;\">\u5f02\u5e38\u7c7b2<\/span>:<\/span><span role=\"presentation\" style=\"box-sizing: border-box; padding-right: 0.1px;\"> \u00a0 \u00a0<span class=\"cm-variable\" style=\"box-sizing: border-box;\">\u8bed\u53e5<\/span><\/span><span role=\"presentation\" style=\"box-sizing: border-box; padding-right: 0.1px;\"><span class=\"cm-keyword\" style=\"box-sizing: border-box; color: rgb(200, 143, 208);\">else<\/span>:<\/span><span role=\"presentation\" style=\"box-sizing: border-box; padding-right: 0.1px;\"> \u00a0 \u00a0<span class=\"cm-variable\" style=\"box-sizing: border-box;\">\u8bed\u53e5<\/span><span class=\"cm-tab\" role=\"presentation\" cm-text=\"\t\" style=\"box-sizing: border-box; font-family: var(--monospace); position: relative; display: inline-block;\">  <\/span><span class=\"cm-comment\" style=\"box-sizing: border-box; color: rgb(218, 146, 74);\"># \u672a\u88ab\u4e0a\u9762\u6355\u6349\u65f6\u6267\u884c<\/span><\/span><span role=\"presentation\" style=\"box-sizing: border-box; padding-right: 0.1px;\"><span class=\"cm-keyword\" style=\"box-sizing: border-box; color: rgb(200, 143, 208);\">finally<\/span>:<\/span><span role=\"presentation\" style=\"box-sizing: border-box; padding-right: 0.1px;\"> \u00a0 \u00a0<span class=\"cm-variable\" style=\"box-sizing: border-box;\">\u8bed\u53e5<\/span><span class=\"cm-tab\" role=\"presentation\" cm-text=\"\t\" style=\"box-sizing: border-box; font-family: var(--monospace); position: relative; display: inline-block;\">  <\/span><span class=\"cm-comment\" style=\"box-sizing: border-box; color: rgb(218, 146, 74);\"># \u4e00\u5b9a\u4f1a\u6267\u884c<\/span><\/span><\/pre><h2 cid=\"n98\" mdtype=\"heading\" class=\"md-end-block md-heading\" style=\"box-sizing: border-box; break-after: avoid-page; break-inside: avoid; orphans: 4; font-size: 1.63rem; margin: 0px 0px 1.5rem; font-family: &quot;Lucida Grande&quot;, Corbel, sans-serif; clear: both; overflow-wrap: break-word; padding: 0px; color: rgb(222, 222, 222); line-height: 1.875rem; letter-spacing: -1px; position: relative;\"><span class=\"ez-toc-section\" id=\"4_%E5%8F%AF%E6%89%A7%E8%A1%8C%E5%AF%B9%E8%B1%A1%E8%A7%A3%E6%9E%90%E5%91%BD%E4%BB%A4\"><\/span><span md-inline=\"plain\" class=\"md-plain\" style=\"box-sizing: border-box;\">4. \u53ef\u6267\u884c\u5bf9\u8c61\u89e3\u6790\u547d\u4ee4<\/span><span class=\"ez-toc-section-end\"><\/span><\/h2><ul class=\"ul-list\" cid=\"n99\" mdtype=\"list\" data-mark=\"-\" style=\"margin-top: 0px; margin-bottom: 1.5rem; padding: 0px 0px 0px 1.875rem; list-style-type: square; position: relative; color: rgb(184, 191, 198); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, &quot;Segoe UI Emoji&quot;, sans-serif; white-space-collapse: collapse;\"><li class=\"md-list-item\" cid=\"n100\" mdtype=\"list_item\" style=\"box-sizing: border-box; margin: 0px; position: relative;\"><p cid=\"n101\" mdtype=\"paragraph\" class=\"md-end-block md-p\" style=\"box-sizing: border-box; line-height: inherit; orphans: 4; margin: 0px 0px 0.5rem; overflow-wrap: break-word; white-space-collapse: preserve; position: relative;\"><span md-inline=\"code\" spellcheck=\"false\" class=\"md-pair-s\" style=\"box-sizing: border-box;\"><code style=\"box-sizing: border-box; font-family: Monaco, Consolas, &quot;Andale Mono&quot;, &quot;DejaVu Sans Mono&quot;, monospace; vertical-align: initial; font-size: 0.875em; background: rgba(0, 0, 0, 0.05); padding: 2px 5px;\">exec<\/code><\/span><span md-inline=\"plain\" class=\"md-plain\" style=\"box-sizing: border-box;\">\u8bed\u53e5\u7528\u6765\u6267\u884c\u5b58\u50a8\u5728\u4ee3\u7801\u5bf9\u8c61\u3001\u5b57\u7b26\u4e32\u3001\u6587\u4ef6\u4e2d\u7684Python\u8bed\u53e5<\/span><\/p><\/li><li class=\"md-list-item\" cid=\"n102\" mdtype=\"list_item\" style=\"box-sizing: border-box; margin: 0px; position: relative;\"><p cid=\"n103\" mdtype=\"paragraph\" class=\"md-end-block md-p\" style=\"box-sizing: border-box; line-height: inherit; orphans: 4; margin: 0px 0px 0.5rem; overflow-wrap: break-word; white-space-collapse: preserve; position: relative;\"><span md-inline=\"code\" spellcheck=\"false\" class=\"md-pair-s\" style=\"box-sizing: border-box;\"><code style=\"box-sizing: border-box; font-family: Monaco, Consolas, &quot;Andale Mono&quot;, &quot;DejaVu Sans Mono&quot;, monospace; vertical-align: initial; font-size: 0.875em; background: rgba(0, 0, 0, 0.05); padding: 2px 5px;\">eval<\/code><\/span><span md-inline=\"plain\" class=\"md-plain\" style=\"box-sizing: border-box;\"> \u8bed\u53e5\u7528\u6765\u8ba1\u7b97\u5b58\u50a8\u5728\u4ee3\u7801\u5bf9\u8c61\u6216\u5b57\u7b26\u4e32\u4e2d\u7684\u6709\u6548\u7684Python\u8868\u8fbe\u5f0f<\/span><\/p><\/li><li class=\"md-list-item\" cid=\"n104\" mdtype=\"list_item\" style=\"box-sizing: border-box; margin: 0px; position: relative;\"><p cid=\"n105\" mdtype=\"paragraph\" class=\"md-end-block md-p\" style=\"box-sizing: border-box; line-height: inherit; orphans: 4; margin: 0px 0px 0.5rem; overflow-wrap: break-word; white-space-collapse: preserve; position: relative;\"><span md-inline=\"code\" spellcheck=\"false\" class=\"md-pair-s\" style=\"box-sizing: border-box;\"><code style=\"box-sizing: border-box; font-family: Monaco, Consolas, &quot;Andale Mono&quot;, &quot;DejaVu Sans Mono&quot;, monospace; vertical-align: initial; font-size: 0.875em; background: rgba(0, 0, 0, 0.05); padding: 2px 5px;\">compile<\/code><\/span><span md-inline=\"plain\" class=\"md-plain\" style=\"box-sizing: border-box;\">\u8bed\u53e5\u5219\u63d0\u4f9b\u4e86\u5b57\u8282\u7f16\u7801\u7684\u9884\u7f16\u8bd1<\/span><\/p><\/li><\/ul><pre class=\"md-fences md-end-block ty-contain-cm modeLoaded\" spellcheck=\"false\" lang=\"python\" cid=\"n106\" mdtype=\"fences\" style=\"box-sizing: border-box; overflow: visible; font-family: Monaco, Consolas, &quot;Andale Mono&quot;, &quot;DejaVu Sans Mono&quot;, monospace; margin-top: 0px; margin-bottom: 20px; font-size: 0.9rem; break-inside: avoid; white-space: normal; background: rgb(51, 51, 51); padding: 10px 10px 10px 30px; width: inherit; color: rgb(184, 191, 198); position: relative !important;\"><span role=\"presentation\" style=\"box-sizing: border-box; padding-right: 0.1px;\"><span class=\"cm-builtin\" style=\"box-sizing: border-box; color: rgb(243, 179, 248);\">eval<\/span>(<span class=\"cm-builtin\" style=\"box-sizing: border-box; color: rgb(243, 179, 248);\">compile<\/span>( <span class=\"cm-string\" style=\"box-sizing: border-box; color: rgb(210, 107, 107);\">'print(3 + 6)'<\/span>, <span class=\"cm-string\" style=\"box-sizing: border-box; color: rgb(210, 107, 107);\">''<\/span>, <span class=\"cm-string\" style=\"box-sizing: border-box; color: rgb(210, 107, 107);\">'exec'<\/span>))<\/span><\/pre><p cid=\"n107\" mdtype=\"paragraph\" class=\"md-end-block md-p\" style=\"box-sizing: border-box; line-height: inherit; orphans: 4; margin-top: 0px; margin-bottom: 1.5rem; overflow-wrap: break-word; position: relative; color: rgb(184, 191, 198); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, &quot;Segoe UI Emoji&quot;, sans-serif; font-size: 16px;\"><span md-inline=\"strong\" class=\"md-pair-s \" style=\"box-sizing: border-box;\"><strong style=\"box-sizing: border-box; color: rgb(222, 222, 222);\">\u6ce8\u610f\u4e8b\u9879: <\/strong><\/span><\/p><ul class=\"ul-list\" cid=\"n108\" mdtype=\"list\" data-mark=\"-\" style=\"margin-top: 0px; margin-bottom: 1.5rem; padding: 0px 0px 0px 1.875rem; list-style-type: square; position: relative; color: rgb(184, 191, 198); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, &quot;Segoe UI Emoji&quot;, sans-serif; white-space-collapse: collapse;\"><li class=\"md-list-item\" cid=\"n109\" mdtype=\"list_item\" style=\"box-sizing: border-box; margin: 0px; position: relative;\"><p cid=\"n110\" mdtype=\"paragraph\" class=\"md-end-block md-p\" style=\"box-sizing: border-box; line-height: inherit; orphans: 4; margin: 0px 0px 0.5rem; overflow-wrap: break-word; white-space-collapse: preserve; position: relative;\"><span md-inline=\"code\" spellcheck=\"false\" class=\"md-pair-s\" style=\"box-sizing: border-box;\"><code style=\"box-sizing: border-box; font-family: Monaco, Consolas, &quot;Andale Mono&quot;, &quot;DejaVu Sans Mono&quot;, monospace; vertical-align: initial; font-size: 0.875em; background: rgba(0, 0, 0, 0.05); padding: 2px 5px;\">eval<\/code><\/span><span md-inline=\"plain\" class=\"md-plain\" style=\"box-sizing: border-box;\">\u51fd\u6570\u53ea\u8d1f\u8d23\u5bf9\u8868\u8fbe\u5f0f\u8fdb\u884c\u5904\u7406(\u5bf9\u8f93\u5165\u8fdb\u884c\u8f93\u51fa), \u5e76\u6ca1\u6709\u8d4b\u503c\u7684\u529f\u80fd, \u672c\u8eab\u662f\u6ca1\u6709\u5f71\u54cd\u5f53\u524d\u4ee3\u7801\u73af\u5883\u7684\u80fd\u529b. \u82e5\u9700\u8981\u5904\u7406\u8d4b\u503c\u8868\u8fbe\u5f0f, \u5219\u9700\u8981\u4f7f\u7528<\/span><span md-inline=\"code\" spellcheck=\"false\" class=\"md-pair-s\" style=\"box-sizing: border-box;\"><code style=\"box-sizing: border-box; font-family: Monaco, Consolas, &quot;Andale Mono&quot;, &quot;DejaVu Sans Mono&quot;, monospace; vertical-align: initial; font-size: 0.875em; background: rgba(0, 0, 0, 0.05); padding: 2px 5px;\">exec<\/code><\/span><\/p><\/li><li class=\"md-list-item\" cid=\"n111\" mdtype=\"list_item\" style=\"box-sizing: border-box; margin: 0px; position: relative;\"><p cid=\"n112\" mdtype=\"paragraph\" class=\"md-end-block md-p\" style=\"box-sizing: border-box; line-height: inherit; orphans: 4; margin: 0px 0px 0.5rem; overflow-wrap: break-word; white-space-collapse: preserve; position: relative;\"><span md-inline=\"plain\" class=\"md-plain\" style=\"box-sizing: border-box;\">\u7f51\u7edc\u5b89\u5168\u6027\u8003\u91cf: \u82e5\u7528\u6237\u8f93\u5165<\/span><\/p><\/li><\/ul><pre class=\"md-fences md-end-block ty-contain-cm modeLoaded\" spellcheck=\"false\" lang=\"python\" cid=\"n113\" mdtype=\"fences\" style=\"box-sizing: border-box; overflow: visible; font-family: Monaco, Consolas, &quot;Andale Mono&quot;, &quot;DejaVu Sans Mono&quot;, monospace; margin-top: 0px; margin-bottom: 20px; font-size: 0.9rem; break-inside: avoid; white-space: normal; background: rgb(51, 51, 51); padding: 10px 10px 10px 30px; width: inherit; color: rgb(184, 191, 198); position: relative !important;\"><span role=\"presentation\" style=\"box-sizing: border-box; padding-right: 0.1px;\"><span class=\"cm-builtin\" style=\"box-sizing: border-box; color: rgb(243, 179, 248);\">__import__<\/span>(<span class=\"cm-string\" style=\"box-sizing: border-box; color: rgb(210, 107, 107);\">'os'<\/span>).<span class=\"cm-property\" style=\"box-sizing: border-box;\">system<\/span>(<span class=\"cm-string\" style=\"box-sizing: border-box; color: rgb(210, 107, 107);\">'dir'<\/span>)<\/span><\/pre><p cid=\"n114\" mdtype=\"paragraph\" class=\"md-end-block md-p\" style=\"box-sizing: border-box; line-height: inherit; orphans: 4; margin-top: 0px; margin-bottom: 1.5rem; overflow-wrap: break-word; position: relative; color: rgb(184, 191, 198); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, &quot;Segoe UI Emoji&quot;, sans-serif; font-size: 16px;\"><span md-inline=\"plain\" class=\"md-plain\" style=\"box-sizing: border-box;\">\u5f53\u524d\u76ee\u5f55\u7684\u6587\u4ef6\u5939\u90fd\u4f1a\u5c55\u73b0\u5728\u7528\u6237\u524d\u9762, \u4e5f\u53ef\u4ee5\u4f7f\u7528 read, remove \u7b49\u65b9\u6cd5\u63a7\u5236\u670d\u52a1\u5668<\/span><\/p><p cid=\"n115\" mdtype=\"paragraph\" class=\"md-end-block md-p\" style=\"box-sizing: border-box; line-height: inherit; orphans: 4; margin-top: 0px; margin-bottom: 1.5rem; overflow-wrap: break-word; position: relative; color: rgb(184, 191, 198); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, &quot;Segoe UI Emoji&quot;, sans-serif; font-size: 16px;\"><span md-inline=\"plain\" class=\"md-plain\" style=\"box-sizing: border-box;\">\u5b9e\u9645\u4f7f\u7528\u65f6, \u53ef\u4ee5\u5bf9\u7528\u6237\u8f93\u5165\u7684\u8bed\u53e5\u8fdb\u884c\u68c0\u67e5; \u4e5f\u53ef\u4ee5\u4f7f\u7528 ast \u6a21\u5757\u7684 <\/span><span md-inline=\"code\" spellcheck=\"false\" class=\"md-pair-s\" style=\"box-sizing: border-box;\"><code style=\"box-sizing: border-box; font-family: Monaco, Consolas, &quot;Andale Mono&quot;, &quot;DejaVu Sans Mono&quot;, monospace; vertical-align: initial; font-size: 0.875em; background: rgba(0, 0, 0, 0.05); padding: 2px 5px;\">literal_eval<\/code><\/span><span md-inline=\"plain\" class=\"md-plain\" style=\"box-sizing: border-box;\"> \u4ee3\u66ff<\/span><\/p><pre class=\"md-fences md-end-block ty-contain-cm modeLoaded\" spellcheck=\"false\" lang=\"python\" cid=\"n116\" mdtype=\"fences\" style=\"box-sizing: border-box; overflow: visible; font-family: Monaco, Consolas, &quot;Andale Mono&quot;, &quot;DejaVu Sans Mono&quot;, monospace; margin-top: 0px; margin-bottom: 20px; font-size: 0.9rem; break-inside: avoid; white-space: normal; background: rgb(51, 51, 51); padding: 10px 10px 10px 30px; width: inherit; color: rgb(184, 191, 198); position: relative !important;\"><span role=\"presentation\" style=\"box-sizing: border-box; padding-right: 0.1px;\"><span class=\"cm-keyword\" style=\"box-sizing: border-box; color: rgb(200, 143, 208);\">import<\/span> <span class=\"cm-variable\" style=\"box-sizing: border-box;\">ast<\/span><\/span><span role=\"presentation\" style=\"box-sizing: border-box; padding-right: 0.1px;\"><span class=\"cm-builtin\" style=\"box-sizing: border-box; color: rgb(243, 179, 248);\">eval<\/span> = <span class=\"cm-variable\" style=\"box-sizing: border-box;\">ast<\/span>.<span class=\"cm-property\" style=\"box-sizing: border-box;\">literal_eval<\/span><\/span><\/pre><h2 cid=\"n117\" mdtype=\"heading\" class=\"md-end-block md-heading\" style=\"box-sizing: border-box; break-after: avoid-page; break-inside: avoid; orphans: 4; font-size: 1.63rem; margin: 0px 0px 1.5rem; font-family: &quot;Lucida Grande&quot;, Corbel, sans-serif; clear: both; overflow-wrap: break-word; padding: 0px; color: rgb(222, 222, 222); line-height: 1.875rem; letter-spacing: -1px; position: relative;\"><span class=\"ez-toc-section\" id=\"5_IO_%E6%93%8D%E4%BD%9C\"><\/span><span md-inline=\"plain\" class=\"md-plain\" style=\"box-sizing: border-box;\">5. IO \u64cd\u4f5c<\/span><span class=\"ez-toc-section-end\"><\/span><\/h2><h3 cid=\"n118\" mdtype=\"heading\" class=\"md-end-block md-heading\" style=\"box-sizing: border-box; break-after: avoid-page; break-inside: avoid; orphans: 4; font-size: 1.17rem; margin: 0px 0px 1.5rem; font-family: &quot;Lucida Grande&quot;, Corbel, sans-serif; clear: both; overflow-wrap: break-word; padding: 0px; color: rgb(222, 222, 222); line-height: 1.5rem; letter-spacing: -1px; position: relative;\"><span class=\"ez-toc-section\" id=\"1_%E6%89%93%E5%BC%80%E6%96%87%E4%BB%B6\"><\/span><span md-inline=\"plain\" class=\"md-plain\" style=\"box-sizing: border-box;\">(1) \u6253\u5f00\u6587\u4ef6<\/span><span class=\"ez-toc-section-end\"><\/span><\/h3><p cid=\"n119\" mdtype=\"paragraph\" class=\"md-end-block md-p\" style=\"box-sizing: border-box; line-height: inherit; orphans: 4; margin-top: 0px; margin-bottom: 1.5rem; overflow-wrap: break-word; position: relative; color: rgb(184, 191, 198); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, &quot;Segoe UI Emoji&quot;, sans-serif; font-size: 16px;\"><span md-inline=\"plain\" class=\"md-plain\" style=\"box-sizing: border-box;\">\u6253\u5f00\u6587\u4ef6\u6709\u4e24\u79cd\u65b9\u5f0f, \u4e00\u79cd\u662f open - close \u8bed\u53e5, \u4e00\u79cd\u662f with \u4e0a\u4e0b\u6587\u7ba1\u7406. <\/span><\/p><pre class=\"md-fences md-end-block ty-contain-cm modeLoaded\" spellcheck=\"false\" lang=\"python\" cid=\"n120\" mdtype=\"fences\" style=\"box-sizing: border-box; overflow: visible; font-family: Monaco, Consolas, &quot;Andale Mono&quot;, &quot;DejaVu Sans Mono&quot;, monospace; margin-top: 0px; margin-bottom: 20px; font-size: 0.9rem; break-inside: avoid; white-space: normal; background: rgb(51, 51, 51); padding: 10px 10px 10px 30px; width: inherit; color: rgb(184, 191, 198); position: relative !important;\"><span role=\"presentation\" style=\"box-sizing: border-box; padding-right: 0.1px;\"><span class=\"cm-variable\" style=\"box-sizing: border-box;\">f<\/span> = <span class=\"cm-builtin\" style=\"box-sizing: border-box; color: rgb(243, 179, 248);\">open<\/span>(<span class=\"cm-string\" style=\"box-sizing: border-box; color: rgb(210, 107, 107);\">'\u8def\u5f84'<\/span>,<span class=\"cm-string\" style=\"box-sizing: border-box; color: rgb(210, 107, 107);\">'\u6253\u5f00\u6a21\u5f0f'<\/span>)<\/span><span role=\"presentation\" style=\"box-sizing: border-box; padding-right: 0.1px;\"><span class=\"cm-comment\" style=\"box-sizing: border-box; color: rgb(218, 146, 74);\"># TODO \u6267\u884c\u7684\u64cd\u4f5c<\/span><\/span><span role=\"presentation\" style=\"box-sizing: border-box; padding-right: 0.1px;\"><span class=\"cm-variable\" style=\"box-sizing: border-box;\">f<\/span>.<span class=\"cm-property\" style=\"box-sizing: border-box;\">close<\/span>() \u00a0 <span class=\"cm-comment\" style=\"box-sizing: border-box; color: rgb(218, 146, 74);\"># \u5982\u679c\u6ca1\u6709 close, \u6587\u4ef6\u5c06\u4e00\u76f4\u5904\u4e8e\u5360\u7528\u72b6\u6001<\/span><\/span><span role=\"presentation\" class=\"cm-tab-wrap-hack\" style=\"box-sizing: border-box; padding-right: 0.1px;\"><span class=\"cm-comment\" style=\"box-sizing: border-box; color: rgb(218, 146, 74);\"># f.closed<span class=\"cm-tab\" role=\"presentation\" cm-text=\"\t\" style=\"box-sizing: border-box; font-family: var(--monospace); position: relative; display: inline-block;\">  <\/span># \u67e5\u770b\u6587\u4ef6\u662f\u5426\u5df2\u7ecf\u5173\u95ed<\/span><\/span><\/pre><pre class=\"md-fences md-end-block ty-contain-cm modeLoaded\" spellcheck=\"false\" lang=\"python\" cid=\"n121\" mdtype=\"fences\" style=\"box-sizing: border-box; overflow: visible; font-family: Monaco, Consolas, &quot;Andale Mono&quot;, &quot;DejaVu Sans Mono&quot;, monospace; margin-top: 0px; margin-bottom: 20px; font-size: 0.9rem; break-inside: avoid; white-space: normal; background: rgb(51, 51, 51); padding: 10px 10px 10px 30px; width: inherit; color: rgb(184, 191, 198); position: relative !important;\"><span role=\"presentation\" style=\"box-sizing: border-box; padding-right: 0.1px;\"><span class=\"cm-keyword\" style=\"box-sizing: border-box; color: rgb(200, 143, 208);\">with<\/span> <span class=\"cm-builtin\" style=\"box-sizing: border-box; color: rgb(243, 179, 248);\">open<\/span>(<span class=\"cm-string\" style=\"box-sizing: border-box; color: rgb(210, 107, 107);\">'\u8def\u5f84'<\/span>,<span class=\"cm-string\" style=\"box-sizing: border-box; color: rgb(210, 107, 107);\">'\u6253\u5f00\u6a21\u5f0f'<\/span>) <span class=\"cm-keyword\" style=\"box-sizing: border-box; color: rgb(200, 143, 208);\">as<\/span> <span class=\"cm-variable\" style=\"box-sizing: border-box;\">file<\/span>:<\/span><span role=\"presentation\" style=\"box-sizing: border-box; padding-right: 0.1px;\"> \u00a0 \u00a0<span class=\"cm-comment\" style=\"box-sizing: border-box; color: rgb(218, 146, 74);\"># TODO \u6267\u884c\u7684\u64cd\u4f5c<\/span><\/span><\/pre><p cid=\"n122\" mdtype=\"paragraph\" class=\"md-end-block md-p\" style=\"box-sizing: border-box; line-height: inherit; orphans: 4; margin-top: 0px; margin-bottom: 1.5rem; overflow-wrap: break-word; position: relative; color: rgb(184, 191, 198); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, &quot;Segoe UI Emoji&quot;, sans-serif; font-size: 16px;\"><span md-inline=\"plain\" class=\"md-plain\" style=\"box-sizing: border-box;\">\u4e00\u822c\u5efa\u8bae\u4f7f\u7528\u540e\u8005, \u5728\u6587\u4ef6\u8bfb\u5199\u7ed3\u675f\u540e\u81ea\u52a8\u5173\u95ed\u6587\u4ef6. \u8fd9\u91cc\u7684\u8def\u5f84\u53ef\u4ee5\u662f\u76f8\u5bf9\u8def\u5f84\u4e5f\u53ef\u4ee5\u662f\u7edd\u5bf9\u8def\u5f84. \u5982\u679c\u662f\u7edd\u5bf9\u8def\u5f84, \u4e00\u822c\u7ed3\u5408 os \u6a21\u5757\u4f7f\u7528. <\/span><\/p><h3 cid=\"n123\" mdtype=\"heading\" class=\"md-end-block md-heading\" style=\"box-sizing: border-box; break-after: avoid-page; break-inside: avoid; orphans: 4; font-size: 1.17rem; margin: 0px 0px 1.5rem; font-family: &quot;Lucida Grande&quot;, Corbel, sans-serif; clear: both; overflow-wrap: break-word; padding: 0px; color: rgb(222, 222, 222); line-height: 1.5rem; letter-spacing: -1px; position: relative;\"><span class=\"ez-toc-section\" id=\"2_%E6%89%93%E5%BC%80%E6%A8%A1%E5%BC%8F\"><\/span><span md-inline=\"plain\" class=\"md-plain\" style=\"box-sizing: border-box;\">(2) \u6253\u5f00\u6a21\u5f0f<\/span><span class=\"ez-toc-section-end\"><\/span><\/h3><pre class=\"md-fences md-end-block ty-contain-cm modeLoaded\" spellcheck=\"false\" lang=\"python\" cid=\"n124\" mdtype=\"fences\" style=\"box-sizing: border-box; overflow: visible; font-family: Monaco, Consolas, &quot;Andale Mono&quot;, &quot;DejaVu Sans Mono&quot;, monospace; margin-top: 0px; margin-bottom: 20px; font-size: 0.9rem; break-inside: avoid; white-space: normal; background: rgb(51, 51, 51); padding: 10px 10px 10px 30px; width: inherit; color: rgb(184, 191, 198); position: relative !important;\"><span role=\"presentation\" style=\"box-sizing: border-box; padding-right: 0.1px;\"><span class=\"cm-variable\" style=\"box-sizing: border-box;\">r<\/span><span class=\"cm-tab\" role=\"presentation\" cm-text=\"\t\" style=\"box-sizing: border-box; font-family: var(--monospace); position: relative; display: inline-block;\">   <\/span><span class=\"cm-comment\" style=\"box-sizing: border-box; color: rgb(218, 146, 74);\"># (\u9ed8\u8ba4)\u53ea\u8bfb\u6a21\u5f0f, \u6587\u4ef6\u4e0d\u5b58\u5728\u7684\u65f6\u5019\u62a5\u9519, \u4e0d\u53ef\u5199\u5165(\u4e00\u822c\u7528\u6b64\u6a21\u5f0f\u6253\u5f00, \u5728python\u4e2d\u521b\u5efa\u6570\u636e\u526f\u672c)<\/span><\/span><span role=\"presentation\" style=\"box-sizing: border-box; padding-right: 0.1px;\"><span class=\"cm-variable\" style=\"box-sizing: border-box;\">x<\/span><span class=\"cm-tab\" role=\"presentation\" cm-text=\"\t\" style=\"box-sizing: border-box; font-family: var(--monospace); position: relative; display: inline-block;\">   <\/span><span class=\"cm-comment\" style=\"box-sizing: border-box; color: rgb(218, 146, 74);\"># \u5199\u5165\u6a21\u5f0f, \u6587\u4ef6\u4e0d\u5b58\u5728\u7684\u65f6\u5019\u521b\u5efa\u6587\u4ef6, \u6587\u4ef6\u5b58\u5728\u7684\u65f6\u5019\u62a5\u9519<\/span><\/span><span role=\"presentation\" style=\"box-sizing: border-box; padding-right: 0.1px;\"><span class=\"cm-variable\" style=\"box-sizing: border-box;\">w<\/span><span class=\"cm-tab\" role=\"presentation\" cm-text=\"\t\" style=\"box-sizing: border-box; font-family: var(--monospace); position: relative; display: inline-block;\">   <\/span><span class=\"cm-comment\" style=\"box-sizing: border-box; color: rgb(218, 146, 74);\"># \u5199\u5165\u6a21\u5f0f, \u6587\u4ef6\u4e0d\u5b58\u5728\u7684\u65f6\u5019\u521b\u5efa\u6587\u4ef6, \u6587\u4ef6\u5b58\u5728\u7684\u65f6\u5019\u8986\u76d6\u6587\u4ef6<\/span><\/span><span role=\"presentation\" style=\"box-sizing: border-box; padding-right: 0.1px;\"><span class=\"cm-variable\" style=\"box-sizing: border-box;\">a<\/span><span class=\"cm-tab\" role=\"presentation\" cm-text=\"\t\" style=\"box-sizing: border-box; font-family: var(--monospace); position: relative; display: inline-block;\">   <\/span><span class=\"cm-comment\" style=\"box-sizing: border-box; color: rgb(218, 146, 74);\"># \u8ffd\u52a0\u5199\u5165\u6a21\u5f0f, \u6587\u4ef6\u4e0d\u5b58\u5728\u7684\u65f6\u5019\u521b\u5efa\u6587\u4ef6, \u6587\u4ef6\u5b58\u5728\u7684\u65f6\u5019\u5728\u6587\u4ef6\u540e\u5199\u5165\u65b0\u5185\u5bb9<\/span><\/span><span role=\"presentation\" style=\"box-sizing: border-box; padding-right: 0.1px;\"><span class=\"cm-variable\" style=\"box-sizing: border-box;\">b<\/span><span class=\"cm-tab\" role=\"presentation\" cm-text=\"\t\" style=\"box-sizing: border-box; font-family: var(--monospace); position: relative; display: inline-block;\">   <\/span><span class=\"cm-comment\" style=\"box-sizing: border-box; color: rgb(218, 146, 74);\"># \u4ee5\u4e8c\u8fdb\u5236\u8bfb\u53d6\u6587\u4ef6, 'bw','br'<\/span><\/span><span role=\"presentation\" style=\"box-sizing: border-box; padding-right: 0.1px;\"><span class=\"cm-operator\" style=\"box-sizing: border-box;\">+<\/span><span class=\"cm-tab\" role=\"presentation\" cm-text=\"\t\" style=\"box-sizing: border-box; font-family: var(--monospace); position: relative; display: inline-block;\">   <\/span><span class=\"cm-comment\" style=\"box-sizing: border-box; color: rgb(218, 146, 74);\"># \u53ef\u8bfb\u5199\u6a21\u5f0f, 'r+','w+', \u8ffd\u52a0\u5c5e\u6027, \u4e0d\u6539\u53d8\u57fa\u672c\u539f\u5219<\/span><\/span><span role=\"presentation\" style=\"box-sizing: border-box; padding-right: 0.1px;\"><span class=\"cm-variable\" style=\"box-sizing: border-box;\">f<\/span>.<span class=\"cm-property\" style=\"box-sizing: border-box;\">readable<\/span>()<span class=\"cm-tab\" role=\"presentation\" cm-text=\"\t\" style=\"box-sizing: border-box; font-family: var(--monospace); position: relative; display: inline-block;\">    <\/span><span class=\"cm-tab\" role=\"presentation\" cm-text=\"\t\" style=\"box-sizing: border-box; font-family: var(--monospace); position: relative; display: inline-block;\">    <\/span><span class=\"cm-comment\" style=\"box-sizing: border-box; color: rgb(218, 146, 74);\"># \u67e5\u770b\u8fd9\u4e2a\u6a21\u5f0f\u662f\u5426\u53ef\u8bfb<\/span><\/span><span role=\"presentation\" style=\"box-sizing: border-box; padding-right: 0.1px;\"><span class=\"cm-variable\" style=\"box-sizing: border-box;\">f<\/span>.<span class=\"cm-property\" style=\"box-sizing: border-box;\">writeable<\/span>()<span class=\"cm-tab\" role=\"presentation\" cm-text=\"\t\" style=\"box-sizing: border-box; font-family: var(--monospace); position: relative; display: inline-block;\">   <\/span><span class=\"cm-tab\" role=\"presentation\" cm-text=\"\t\" style=\"box-sizing: border-box; font-family: var(--monospace); position: relative; display: inline-block;\">    <\/span><span class=\"cm-comment\" style=\"box-sizing: border-box; color: rgb(218, 146, 74);\"># \u67e5\u770b\u8fd9\u4e2a\u6a21\u5f0f\u662f\u5426\u53ef\u5199<\/span><\/span><span role=\"presentation\" style=\"box-sizing: border-box; padding-right: 0.1px;\"><span cm-text=\"\" cm-zwsp=\"\" style=\"box-sizing: border-box;\">\u200b<\/span><\/span><span role=\"presentation\" style=\"box-sizing: border-box; padding-right: 0.1px;\"><span class=\"cm-comment\" style=\"box-sizing: border-box; color: rgb(218, 146, 74);\"># \u5176\u4ed6\u53c2\u6570 encoding = 'utf8' \u7f16\u7801\u7c7b\u578b<\/span><\/span><\/pre><h3 cid=\"n125\" mdtype=\"heading\" class=\"md-end-block md-heading\" style=\"box-sizing: border-box; break-after: avoid-page; break-inside: avoid; orphans: 4; font-size: 1.17rem; margin: 0px 0px 1.5rem; font-family: &quot;Lucida Grande&quot;, Corbel, sans-serif; clear: both; overflow-wrap: break-word; padding: 0px; color: rgb(222, 222, 222); line-height: 1.5rem; letter-spacing: -1px; position: relative;\"><span class=\"ez-toc-section\" id=\"3_%E6%96%87%E4%BB%B6%E8%AF%BB%E5%8F%96\"><\/span><span md-inline=\"plain\" class=\"md-plain\" style=\"box-sizing: border-box;\">(3) \u6587\u4ef6\u8bfb\u53d6<\/span><span class=\"ez-toc-section-end\"><\/span><\/h3><pre class=\"md-fences md-end-block ty-contain-cm modeLoaded\" spellcheck=\"false\" lang=\"python\" cid=\"n126\" mdtype=\"fences\" style=\"box-sizing: border-box; overflow: visible; font-family: Monaco, Consolas, &quot;Andale Mono&quot;, &quot;DejaVu Sans Mono&quot;, monospace; margin-top: 0px; margin-bottom: 20px; font-size: 0.9rem; break-inside: avoid; white-space: normal; background: rgb(51, 51, 51); padding: 10px 10px 10px 30px; width: inherit; color: rgb(184, 191, 198); position: relative !important;\"><span role=\"presentation\" style=\"box-sizing: border-box; padding-right: 0.1px;\"><span class=\"cm-variable\" style=\"box-sizing: border-box;\">f<\/span>.<span class=\"cm-property\" style=\"box-sizing: border-box;\">read<\/span>() \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0<span class=\"cm-comment\" style=\"box-sizing: border-box; color: rgb(218, 146, 74);\"># \u6307\u9488\u8bfb\u53d6\u6a21\u5f0f, \u9ed8\u8ba4\u8bfb\u53d6\u5168\u6587, \u8fd4\u56destr, \u4e00\u822c\u4f7f\u7528\u6b64\u6a21\u5f0f, \u7ed3\u5408\u5b57\u7b26\u4e32 split \u7b49\u65b9\u6cd5\u4f7f\u7528<\/span><\/span><span role=\"presentation\" style=\"box-sizing: border-box; padding-right: 0.1px;\"><span class=\"cm-variable\" style=\"box-sizing: border-box;\">f<\/span>.<span class=\"cm-property\" style=\"box-sizing: border-box;\">read<\/span>(<span class=\"cm-variable\" style=\"box-sizing: border-box;\">n<\/span>) \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 <span class=\"cm-comment\" style=\"box-sizing: border-box; color: rgb(218, 146, 74);\"># \u8bfb\u53d6n\u4e2a\u5b57\u8282<\/span><\/span><span role=\"presentation\" style=\"box-sizing: border-box; padding-right: 0.1px;\"><span class=\"cm-variable\" style=\"box-sizing: border-box;\">f<\/span>.<span class=\"cm-property\" style=\"box-sizing: border-box;\">next<\/span>()<span class=\"cm-tab\" role=\"presentation\" cm-text=\"\t\" style=\"box-sizing: border-box; font-family: var(--monospace); position: relative; display: inline-block;\">    <\/span><span class=\"cm-tab\" role=\"presentation\" cm-text=\"\t\" style=\"box-sizing: border-box; font-family: var(--monospace); position: relative; display: inline-block;\">    <\/span><span class=\"cm-tab\" role=\"presentation\" cm-text=\"\t\" style=\"box-sizing: border-box; font-family: var(--monospace); position: relative; display: inline-block;\">    <\/span><span class=\"cm-comment\" style=\"box-sizing: border-box; color: rgb(218, 146, 74);\"># \u6307\u9488\u8df3\u8f6c\u5230\u4e0b\u4e00\u4e2a\u4f4d\u7f6e, \u5e76\u8fd4\u56de\u5185\u5bb9<\/span><\/span><span role=\"presentation\" style=\"box-sizing: border-box; padding-right: 0.1px;\"><span class=\"cm-variable\" style=\"box-sizing: border-box;\">f<\/span>.<span class=\"cm-property\" style=\"box-sizing: border-box;\">readline<\/span>() \u00a0 \u00a0 \u00a0 \u00a0<span class=\"cm-comment\" style=\"box-sizing: border-box; color: rgb(218, 146, 74);\"># \u6307\u9488\u6309\u884c\u8bfb\u53d6<\/span><\/span><span role=\"presentation\" style=\"box-sizing: border-box; padding-right: 0.1px;\"><span class=\"cm-variable\" style=\"box-sizing: border-box;\">f<\/span>.<span class=\"cm-property\" style=\"box-sizing: border-box;\">readlines<\/span>() \u00a0 \u00a0 \u00a0 <span class=\"cm-comment\" style=\"box-sizing: border-box; color: rgb(218, 146, 74);\"># \u8bfb\u53d6\u6240\u6709\u884c, \u5e76\u8fd4\u56delist<\/span><\/span><span role=\"presentation\" style=\"box-sizing: border-box; padding-right: 0.1px;\"><span class=\"cm-variable\" style=\"box-sizing: border-box;\">f<\/span>.<span class=\"cm-property\" style=\"box-sizing: border-box;\">seek<\/span>(<span class=\"cm-variable\" style=\"box-sizing: border-box;\">n<\/span>) \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 <span class=\"cm-comment\" style=\"box-sizing: border-box; color: rgb(218, 146, 74);\"># \u6307\u9488\u4f4d\u7f6e\u91cd\u7f6e\u4e3an(0\u4e3a\u6587\u4ef6\u5934)<\/span><\/span><span role=\"presentation\" style=\"box-sizing: border-box; padding-right: 0.1px;\"><span class=\"cm-variable\" style=\"box-sizing: border-box;\">f<\/span>.<span class=\"cm-property\" style=\"box-sizing: border-box;\">tell<\/span>() \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0<span class=\"cm-comment\" style=\"box-sizing: border-box; color: rgb(218, 146, 74);\"># \u5f53\u524d\u6307\u9488\u4f4d\u7f6e<\/span><\/span><\/pre><h3 cid=\"n127\" mdtype=\"heading\" class=\"md-end-block md-heading\" style=\"box-sizing: border-box; break-after: avoid-page; break-inside: avoid; orphans: 4; font-size: 1.17rem; margin: 0px 0px 1.5rem; font-family: &quot;Lucida Grande&quot;, Corbel, sans-serif; clear: both; overflow-wrap: break-word; padding: 0px; color: rgb(222, 222, 222); line-height: 1.5rem; letter-spacing: -1px; position: relative;\"><span class=\"ez-toc-section\" id=\"4_%E5%86%99%E5%85%A5%E6%95%B0%E6%8D%AE\"><\/span><span md-inline=\"plain\" class=\"md-plain\" style=\"box-sizing: border-box;\">(4) \u5199\u5165\u6570\u636e<\/span><span class=\"ez-toc-section-end\"><\/span><\/h3><pre class=\"md-fences md-end-block ty-contain-cm modeLoaded\" spellcheck=\"false\" lang=\"python\" cid=\"n128\" mdtype=\"fences\" style=\"box-sizing: border-box; overflow: visible; font-family: Monaco, Consolas, &quot;Andale Mono&quot;, &quot;DejaVu Sans Mono&quot;, monospace; margin-top: 0px; margin-bottom: 20px; font-size: 0.9rem; break-inside: avoid; white-space: normal; background: rgb(51, 51, 51); padding: 10px 10px 10px 30px; width: inherit; color: rgb(184, 191, 198); position: relative !important;\"><span role=\"presentation\" style=\"box-sizing: border-box; padding-right: 0.1px;\"><span class=\"cm-variable\" style=\"box-sizing: border-box;\">f<\/span>.<span class=\"cm-property\" style=\"box-sizing: border-box;\">write<\/span>(<span class=\"cm-string\" style=\"box-sizing: border-box; color: rgb(210, 107, 107);\">'\u8bed\u53e51\\n\u8bed\u53e52'<\/span>) \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 <span class=\"cm-tab\" role=\"presentation\" cm-text=\"\t\" style=\"box-sizing: border-box; font-family: var(--monospace); position: relative; display: inline-block;\">    <\/span><span class=\"cm-comment\" style=\"box-sizing: border-box; color: rgb(218, 146, 74);\"># \u5199\u5165\u7f13\u5b58<\/span><\/span><span role=\"presentation\" style=\"box-sizing: border-box; padding-right: 0.1px;\"><span class=\"cm-variable\" style=\"box-sizing: border-box;\">f<\/span>.<span class=\"cm-property\" style=\"box-sizing: border-box;\">writelines<\/span>([<span class=\"cm-string\" style=\"box-sizing: border-box; color: rgb(210, 107, 107);\">'\u8bed\u53e51\\n'<\/span>, <span class=\"cm-string\" style=\"box-sizing: border-box; color: rgb(210, 107, 107);\">'\u8bed\u53e52'<\/span>]) <span class=\"cm-tab\" role=\"presentation\" cm-text=\"\t\" style=\"box-sizing: border-box; font-family: var(--monospace); position: relative; display: inline-block;\"> <\/span><span class=\"cm-tab\" role=\"presentation\" cm-text=\"\t\" style=\"box-sizing: border-box; font-family: var(--monospace); position: relative; display: inline-block;\">    <\/span><span class=\"cm-comment\" style=\"box-sizing: border-box; color: rgb(218, 146, 74);\"># \u5199\u5165\u7f13\u5b58, \u591a\u884c\u6570\u636e\u7528\u6b64\u8bed\u53e5<\/span><\/span><span role=\"presentation\" style=\"box-sizing: border-box; padding-right: 0.1px;\"><span class=\"cm-variable\" style=\"box-sizing: border-box;\">f<\/span>.<span class=\"cm-property\" style=\"box-sizing: border-box;\">flush<\/span>() <span class=\"cm-tab\" role=\"presentation\" cm-text=\"\t\" style=\"box-sizing: border-box; font-family: var(--monospace); position: relative; display: inline-block;\">  <\/span><span class=\"cm-tab\" role=\"presentation\" cm-text=\"\t\" style=\"box-sizing: border-box; font-family: var(--monospace); position: relative; display: inline-block;\">    <\/span><span class=\"cm-tab\" role=\"presentation\" cm-text=\"\t\" style=\"box-sizing: border-box; font-family: var(--monospace); position: relative; display: inline-block;\">    <\/span> \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 <span class=\"cm-tab\" role=\"presentation\" cm-text=\"\t\" style=\"box-sizing: border-box; font-family: var(--monospace); position: relative; display: inline-block;\"> <\/span> \u00a0 <span class=\"cm-comment\" style=\"box-sizing: border-box; color: rgb(218, 146, 74);\"># \u51b2\u5237, \u7f13\u5b58\u533a\u5bfc\u5165\u78c1\u76d8<\/span><\/span><\/pre><h3 cid=\"n129\" mdtype=\"heading\" class=\"md-end-block md-heading\" style=\"box-sizing: border-box; break-after: avoid-page; break-inside: avoid; orphans: 4; font-size: 1.17rem; margin: 0px 0px 1.5rem; font-family: &quot;Lucida Grande&quot;, Corbel, sans-serif; clear: both; overflow-wrap: break-word; padding: 0px; color: rgb(222, 222, 222); line-height: 1.5rem; letter-spacing: -1px; position: relative;\"><span class=\"ez-toc-section\" id=\"5_SIO_%E6%93%8D%E4%BD%9C\"><\/span><span md-inline=\"plain\" class=\"md-plain\" style=\"box-sizing: border-box;\">(5) SIO \u64cd\u4f5c<\/span><span class=\"ez-toc-section-end\"><\/span><\/h3><p cid=\"n130\" mdtype=\"paragraph\" class=\"md-end-block md-p\" style=\"box-sizing: border-box; line-height: inherit; orphans: 4; margin-top: 0px; margin-bottom: 1.5rem; overflow-wrap: break-word; position: relative; color: rgb(184, 191, 198); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, &quot;Segoe UI Emoji&quot;, sans-serif; font-size: 16px;\"><span md-inline=\"plain\" class=\"md-plain\" style=\"box-sizing: border-box;\">SIO \u6307\u5c06\u6587\u4ef6\u52a8\u6001\u5185\u5b58\u7ba1\u7406, \u901f\u5ea6\u6781\u5feb, \u4f46\u662f\u5b58\u50a8\u6570\u636e\u91cf\u6709\u9650, \u4f7f\u7528\u65b9\u6cd5\u4e0e IO \u64cd\u4f5c\u7c7b\u4f3c: <\/span><\/p><pre class=\"md-fences md-end-block ty-contain-cm modeLoaded\" spellcheck=\"false\" lang=\"python\" cid=\"n131\" mdtype=\"fences\" style=\"box-sizing: border-box; overflow: visible; font-family: Monaco, Consolas, &quot;Andale Mono&quot;, &quot;DejaVu Sans Mono&quot;, monospace; margin-top: 0px; margin-bottom: 20px; font-size: 0.9rem; break-inside: avoid; white-space: normal; background: rgb(51, 51, 51); padding: 10px 10px 10px 30px; width: inherit; color: rgb(184, 191, 198); position: relative !important;\"><span role=\"presentation\" style=\"box-sizing: border-box; padding-right: 0.1px;\"><span class=\"cm-keyword\" style=\"box-sizing: border-box; color: rgb(200, 143, 208);\">import<\/span> <span class=\"cm-variable\" style=\"box-sizing: border-box;\">io<\/span><\/span><span role=\"presentation\" style=\"box-sizing: border-box; padding-right: 0.1px;\"><span class=\"cm-variable\" style=\"box-sizing: border-box;\">sio<\/span> = <span class=\"cm-variable\" style=\"box-sizing: border-box;\">io<\/span>.<span class=\"cm-property\" style=\"box-sizing: border-box;\">StringIO<\/span>()<\/span><span role=\"presentation\" style=\"box-sizing: border-box; padding-right: 0.1px;\"><span class=\"cm-variable\" style=\"box-sizing: border-box;\">sio<\/span>.<span class=\"cm-property\" style=\"box-sizing: border-box;\">write<\/span>()<\/span><span role=\"presentation\" style=\"box-sizing: border-box; padding-right: 0.1px;\"><span class=\"cm-variable\" style=\"box-sizing: border-box;\">sio<\/span>.<span class=\"cm-property\" style=\"box-sizing: border-box;\">read<\/span>()<\/span><span role=\"presentation\" style=\"box-sizing: border-box; padding-right: 0.1px;\"><span class=\"cm-variable\" style=\"box-sizing: border-box;\">sio<\/span>.<span class=\"cm-property\" style=\"box-sizing: border-box;\">getvalue<\/span>()<\/span><span role=\"presentation\" style=\"box-sizing: border-box; padding-right: 0.1px;\"><span class=\"cm-variable\" style=\"box-sizing: border-box;\">sio<\/span>.<span class=\"cm-property\" style=\"box-sizing: border-box;\">seek<\/span>()<\/span><span role=\"presentation\" style=\"box-sizing: border-box; padding-right: 0.1px;\"><span class=\"cm-variable\" style=\"box-sizing: border-box;\">sio<\/span>.<span class=\"cm-property\" style=\"box-sizing: border-box;\">close<\/span>()<\/span><span role=\"presentation\" style=\"box-sizing: border-box; padding-right: 0.1px;\"><span class=\"cm-comment\" style=\"box-sizing: border-box; color: rgb(218, 146, 74);\"># \u5199\u5165\u5185\u5b58\u4e2d, \u901f\u5ea6\u5feb<\/span><\/span><\/pre><div><span role=\"presentation\" style=\"box-sizing: border-box; padding-right: 0.1px;\"><span class=\"cm-comment\" style=\"box-sizing: border-box; color: rgb(218, 146, 74);\"><\/span><\/span><\/div><\/p>\n","protected":false},"excerpt":{"rendered":"<p>1. \u591a\u76ee\u6807\u8d4b\u503c a,b,c,d,e = &#8216;\u6211\u559c\u6b22\u4f60\u554a&#8217;\u200ba, *b = &#8216;\u6211\u559c\u6b22\u4f60\u554a&#8217;>>> a = &#8216;\u6211&#8217;&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-32","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"views":1191,"_links":{"self":[{"href":"https:\/\/rrt01.cn\/index.php?rest_route=\/wp\/v2\/posts\/32"}],"collection":[{"href":"https:\/\/rrt01.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/rrt01.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/rrt01.cn\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/rrt01.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=32"}],"version-history":[{"count":1,"href":"https:\/\/rrt01.cn\/index.php?rest_route=\/wp\/v2\/posts\/32\/revisions"}],"predecessor-version":[{"id":33,"href":"https:\/\/rrt01.cn\/index.php?rest_route=\/wp\/v2\/posts\/32\/revisions\/33"}],"wp:attachment":[{"href":"https:\/\/rrt01.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=32"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/rrt01.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=32"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/rrt01.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=32"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}