{"id":2031,"date":"2026-06-29T14:22:33","date_gmt":"2026-06-29T06:22:33","guid":{"rendered":"https:\/\/wp.kcra.org.hk\/?p=2031"},"modified":"2026-06-29T14:22:33","modified_gmt":"2026-06-29T06:22:33","slug":"python-%e6%8d%a8%e6%a3%84%e5%82%b3%e7%b5%b1%e8%8a%b1%e6%8b%ac%e8%99%9f%ef%bc%9a%e5%bc%b7%e5%88%b6%e3%80%8c%e7%b8%ae%e6%8e%92%e3%80%8d%e7%9a%84%e8%aa%9e%e6%b3%95%e9%9d%a9%e5%91%bd","status":"publish","type":"post","link":"https:\/\/wp.kcra.org.hk\/?p=2031","title":{"rendered":"Python: \u6368\u68c4\u50b3\u7d71\u82b1\u62ec\u865f\uff1a\u5f37\u5236\u300c\u7e2e\u6392\u300d\u7684\u8a9e\u6cd5\u9769\u547d"},"content":{"rendered":"\n<p><strong>\u6368\u68c4\u50b3\u7d71\u82b1\u62ec\u865f\uff1a\u5f37\u5236\u300c\u7e2e\u6392\u300d\u7684\u8a9e\u6cd5\u9769\u547d<\/strong><\/p>\n<p><strong>\u50b3\u7d71\u8a9e\u8a00\u7684\u4f5c\u6cd5<\/strong><\/p>\n<p>\u5728 C, C++, Java, JavaScript, C# \u7b49\u7d55\u5927\u591a\u6578\u50b3\u7d71\u7a0b\u5f0f\u8a9e\u8a00\u4e2d\uff0c\u7a0b\u5f0f\u78bc\u7684\u7d50\u69cb\u5340\u584a\uff08\u4f8b\u5982 if \u5224\u65b7\u5f0f\u3001for \u8ff4\u5708\uff09\u90fd\u662f\u7528<strong>\u82b1\u62ec\u865f<\/strong><strong> {}<\/strong> \u4f86\u5305\u8986\u7684\u3002\u4f8b\u5982\uff1a<\/p>\n\n\n\n<table style=\"border-collapse: collapse; width: 100%;\">\n<tbody>\n<tr>\n<td style=\"width: 100%;\">\n<p>\/\/ JavaScript \u7bc4\u4f8b<\/p>\n<p>if (score &gt; 60) {<\/p>\n<p>\u00a0\u00a0\u00a0 console.log(&#8220;\u53ca\u683c&#8221;);<\/p>\n}<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n\n\n\n<p>\u5728\u9019\u4e9b\u8a9e\u8a00\u4e2d\uff0c\u7a0b\u5f0f\u78bc\u524d\u9762\u7684\u7a7a\u683c\uff08\u7e2e\u6392\uff09\u7d14\u7cb9\u662f\u70ba\u4e86\u7d66\u4eba\u985e\u95b1\u8b80\u65b9\u4fbf\uff0c\u4e0d\u8ad6\u4f60\u7e2e\u6392\u5e7e\u683c\u3001\u751a\u81f3\u628a\u6240\u6709\u7a0b\u5f0f\u78bc\u5beb\u5728\u540c\u4e00\u884c\uff0c\u96fb\u8166\u90fd\u8b80\u5f97\u61c2\u3002\u9019\u5c0e\u81f4\u5e38\u6709\u5de5\u7a0b\u5e2b\u56e0\u70ba\u6392\u7248\u6df7\u4e82\uff0c\u5f15\u767c\u96e3\u4ee5\u6392\u67e5\u7684\u908f\u8f2f Bug\u3002<\/p>\n\n\n\n<p><strong>Python <\/strong><strong>\u7684\u4f5c\u6cd5<\/strong><\/p>\n<p>\u5409\u591a\u8a8d\u70ba\u300c\u4ee3\u78bc\u88ab\u95b1\u8b80\u7684\u6b21\u6578\uff0c\u9060\u6bd4\u88ab\u7de8\u5beb\u7684\u6b21\u6578\u9084\u8981\u591a\u300d\u3002\u56e0\u6b64 Python \u5927\u81bd\u79fb\u9664\u4e86\u82b1\u62ec\u865f\uff0c\u6539\u7528<strong>\u5f37\u5236\u7e2e\u6392\uff08<\/strong><strong>Indentation<\/strong><strong>\uff09<\/strong>\u4f86\u5b9a\u7fa9\u7a0b\u5f0f\u78bc\u5340\u584a\u3002<\/p>\n\n\n\n<table style=\"border-collapse: collapse; width: 100%;\">\n<tbody>\n<tr>\n<td style=\"width: 100%;\">\n<p># Python \u7bc4\u4f8b<\/p>\n<p>if score &gt; 60:<\/p>\n\u00a0\u00a0\u00a0 print(&#8220;\u53ca\u683c&#8221;)\u00a0 # \u9019\u884c\u5fc5\u9808\u7e2e\u6392\uff0c\u5426\u5247\u76f4\u63a5\u5831\u932f<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n\n\n\n<p><strong>\u6280\u8853\u898f\u7bc4\u8207\u5f71\u97ff<\/strong><\/p>\n<p>\u5728 Python \u4e2d\uff0c\u7e2e\u6392\u662f\u8a9e\u6cd5\u7684\u4e00\u90e8\u5206\u3002\u5982\u679c\u7e2e\u6392\u4e0d\u4e00\u81f4\uff0c\u7cfb\u7d71\u6703\u76f4\u63a5\u62cb\u51fa IndentationError \u932f\u8aa4\u62d2\u7d55\u57f7\u884c\u3002\u5b98\u65b9\u63a8\u85a6\u7684\u898f\u7bc4\uff08PEP 8\uff09\u662f<strong>\u6bcf\u6b21\u7e2e\u6392\u4f7f\u7528<\/strong><strong> 4 <\/strong><strong>\u500b\u7a7a\u683c<\/strong>\u3002\u9019\u500b\u8a2d\u8a08\u5f37\u8feb\u6240\u6709\u4eba\u5728\u64b0\u5beb\u4ee3\u78bc\u6642\u5fc5\u9808\u4fdd\u6301\u6574\u6f54\uff0c\u5927\u5927\u63d0\u5347\u4e86\u958b\u6e90\u5c08\u6848\u8207\u5927\u578b\u5718\u968a\u5354\u4f5c\u6642\u7684\u4ee3\u78bc\u53ef\u8b80\u6027\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6368\u68c4\u50b3\u7d71\u82b1\u62ec\u865f\uff1a\u5f37\u5236\u300c\u7e2e\u6392\u300d\u7684\u8a9e\u6cd5\u9769\u547d \u50b3\u7d71\u8a9e\u8a00\u7684\u4f5c\u6cd5 \u5728 C, C++, Java, JavaScript, &hellip; <a href=\"https:\/\/wp.kcra.org.hk\/?p=2031\" class=\"more-link\">\u95b1\u8b80\u5168\u6587 <span class=\"screen-reader-text\">Python: \u6368\u68c4\u50b3\u7d71\u82b1\u62ec\u865f\uff1a\u5f37\u5236\u300c\u7e2e\u6392\u300d\u7684\u8a9e\u6cd5\u9769\u547d<\/span> <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":50,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9],"tags":[],"class_list":["post-2031","post","type-post","status-publish","format-standard","hentry","category-9"],"_links":{"self":[{"href":"https:\/\/wp.kcra.org.hk\/index.php?rest_route=\/wp\/v2\/posts\/2031","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wp.kcra.org.hk\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/wp.kcra.org.hk\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/wp.kcra.org.hk\/index.php?rest_route=\/wp\/v2\/users\/50"}],"replies":[{"embeddable":true,"href":"https:\/\/wp.kcra.org.hk\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2031"}],"version-history":[{"count":1,"href":"https:\/\/wp.kcra.org.hk\/index.php?rest_route=\/wp\/v2\/posts\/2031\/revisions"}],"predecessor-version":[{"id":2032,"href":"https:\/\/wp.kcra.org.hk\/index.php?rest_route=\/wp\/v2\/posts\/2031\/revisions\/2032"}],"wp:attachment":[{"href":"https:\/\/wp.kcra.org.hk\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2031"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/wp.kcra.org.hk\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2031"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/wp.kcra.org.hk\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2031"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}