{"id":265,"date":"2025-10-10T11:12:55","date_gmt":"2025-10-10T03:12:55","guid":{"rendered":"http:\/\/www.pyteam.cn\/?p=265"},"modified":"2025-10-10T11:12:55","modified_gmt":"2025-10-10T03:12:55","slug":"%e9%ab%98%e6%96%af%e6%b1%82%e5%92%8c%ef%bc%881%e5%88%b0100%e7%9a%84%e5%92%8c%ef%bc%89-8-2","status":"publish","type":"post","link":"http:\/\/www.pyteam.cn\/index.php\/2025\/10\/10\/%e9%ab%98%e6%96%af%e6%b1%82%e5%92%8c%ef%bc%881%e5%88%b0100%e7%9a%84%e5%92%8c%ef%bc%89-8-2\/","title":{"rendered":"\u9ad8\u65af\u6c42\u548c\uff081\u5230100\u7684\u548c\uff09 8.2"},"content":{"rendered":"\n<div class=\"wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:clamp(18px, 1.125rem, 27px);font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#90A4AE;--cbp-line-number-width:calc(1 * 0.6 * 1.125rem);line-height:clamp(26px, 1.625rem, 39px);--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:flex;align-items:center;padding:10px 0px 10px 16px;margin-bottom:-2px;width:100%;text-align:left;background-color:#ededed;color:#8198a3\">Python<\/span><span role=\"button\" tabindex=\"0\" style=\"color:#90A4AE;display:none\" aria-label=\"\u590d\u5236\" class=\"code-block-pro-copy-button\"><pre class=\"code-block-pro-copy-button-pre\" aria-hidden=\"true\"><textarea class=\"code-block-pro-copy-button-textarea\" tabindex=\"-1\" aria-hidden=\"true\" readonly>total = 0  # \u7d2f\u52a0\u548c\ni = 1      # \u4ece1\u5f00\u59cb\nwhile i &lt;= 100:  # \u5faa\u73af\u6761\u4ef6\uff1ai\u5c0f\u4e8e\u7b49\u4e8e100\n    total = total + i  # \u7d2f\u52a0\n    i = i + 1          # i\u589e\u52a01\nprint(\"1\u5230100\u7684\u548c\u662f\uff1a\", total)<\/textarea><\/pre><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki material-theme-lighter\" style=\"background-color: #FAFAFA\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #90A4AE\">total <\/span><span style=\"color: #39ADB5\">=<\/span><span style=\"color: #90A4AE\"> <\/span><span style=\"color: #F76D47\">0<\/span><span style=\"color: #90A4AE\">  <\/span><span style=\"color: #90A4AE; font-style: italic\"># \u7d2f\u52a0\u548c<\/span><\/span>\n<span class=\"line\"><span style=\"color: #90A4AE\">i <\/span><span style=\"color: #39ADB5\">=<\/span><span style=\"color: #90A4AE\"> <\/span><span style=\"color: #F76D47\">1<\/span><span style=\"color: #90A4AE\">      <\/span><span style=\"color: #90A4AE; font-style: italic\"># \u4ece1\u5f00\u59cb<\/span><\/span>\n<span class=\"line\"><span style=\"color: #39ADB5; font-style: italic\">while<\/span><span style=\"color: #90A4AE\"> i <\/span><span style=\"color: #39ADB5\">&lt;=<\/span><span style=\"color: #90A4AE\"> <\/span><span style=\"color: #F76D47\">100<\/span><span style=\"color: #39ADB5\">:<\/span><span style=\"color: #90A4AE\">  <\/span><span style=\"color: #90A4AE; font-style: italic\"># \u5faa\u73af\u6761\u4ef6\uff1ai\u5c0f\u4e8e\u7b49\u4e8e100<\/span><\/span>\n<span class=\"line\"><span style=\"color: #90A4AE\">    total <\/span><span style=\"color: #39ADB5\">=<\/span><span style=\"color: #90A4AE\"> total <\/span><span style=\"color: #39ADB5\">+<\/span><span style=\"color: #90A4AE\"> i  <\/span><span style=\"color: #90A4AE; font-style: italic\"># \u7d2f\u52a0<\/span><\/span>\n<span class=\"line\"><span style=\"color: #90A4AE\">    i <\/span><span style=\"color: #39ADB5\">=<\/span><span style=\"color: #90A4AE\"> i <\/span><span style=\"color: #39ADB5\">+<\/span><span style=\"color: #90A4AE\"> <\/span><span style=\"color: #F76D47\">1<\/span><span style=\"color: #90A4AE\">          <\/span><span style=\"color: #90A4AE; font-style: italic\"># i\u589e\u52a01<\/span><\/span>\n<span class=\"line\"><span style=\"color: #6182B8\">print<\/span><span style=\"color: #39ADB5\">(<\/span><span style=\"color: #39ADB5\">&quot;<\/span><span style=\"color: #91B859\">1\u5230100\u7684\u548c\u662f\uff1a<\/span><span style=\"color: #39ADB5\">&quot;<\/span><span style=\"color: #39ADB5\">,<\/span><span style=\"color: #6182B8\"> total<\/span><span style=\"color: #39ADB5\">)<\/span><\/span><\/code><\/pre><\/div>\n","protected":false},"excerpt":{"rendered":"","protected":false},"author":1,"featured_media":88,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[17,5],"tags":[],"class_list":["post-265","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-while","category-5"],"views":178,"_links":{"self":[{"href":"http:\/\/www.pyteam.cn\/index.php\/wp-json\/wp\/v2\/posts\/265","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.pyteam.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.pyteam.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.pyteam.cn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.pyteam.cn\/index.php\/wp-json\/wp\/v2\/comments?post=265"}],"version-history":[{"count":1,"href":"http:\/\/www.pyteam.cn\/index.php\/wp-json\/wp\/v2\/posts\/265\/revisions"}],"predecessor-version":[{"id":266,"href":"http:\/\/www.pyteam.cn\/index.php\/wp-json\/wp\/v2\/posts\/265\/revisions\/266"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/www.pyteam.cn\/index.php\/wp-json\/wp\/v2\/media\/88"}],"wp:attachment":[{"href":"http:\/\/www.pyteam.cn\/index.php\/wp-json\/wp\/v2\/media?parent=265"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.pyteam.cn\/index.php\/wp-json\/wp\/v2\/categories?post=265"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.pyteam.cn\/index.php\/wp-json\/wp\/v2\/tags?post=265"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}