{"id":321,"date":"2025-10-10T15:24:48","date_gmt":"2025-10-10T07:24:48","guid":{"rendered":"http:\/\/www.pyteam.cn\/?p=321"},"modified":"2025-10-14T14:51:28","modified_gmt":"2025-10-14T06:51:28","slug":"%e7%bb%98%e5%88%b6%e5%90%8c%e5%bf%83%e6%ad%a3%e5%a4%9a%e8%be%b9%e5%bd%a2-12-3","status":"publish","type":"post","link":"http:\/\/www.pyteam.cn\/index.php\/2025\/10\/10\/%e7%bb%98%e5%88%b6%e5%90%8c%e5%bf%83%e6%ad%a3%e5%a4%9a%e8%be%b9%e5%bd%a2-12-3\/","title":{"rendered":"\u7ed8\u5236\u540c\u5fc3\u6b63\u591a\u8fb9\u5f62 12.3"},"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(2 * 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>import turtle as t\n\n# \u521b\u5efa\u6d77\u9f9f\npen = t.Turtle()\n\n# \u7ed8\u52363\u4e2a\u540c\u5fc3\u6b63\u516d\u8fb9\u5f62\nn = 6  # \u516d\u8fb9\u5f62\n\nfor size in &#91;50, 80, 110&#93;:  # \u4e0d\u540c\u7684\u8fb9\u957f\n    pen.penup()\n    pen.goto(-size\/2, -size\/2)  # \u8c03\u6574\u8d77\u59cb\u4f4d\u7f6e\u4f7f\u56fe\u5f62\u5c45\u4e2d\n    pen.pendown()\n    \n    for i in range(n):\n        pen.forward(size)\n        pen.right(360\/n)<\/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: #39ADB5; font-style: italic\">import<\/span><span style=\"color: #90A4AE\"> turtle <\/span><span style=\"color: #39ADB5; font-style: italic\">as<\/span><span style=\"color: #90A4AE\"> t<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #90A4AE; font-style: italic\"># \u521b\u5efa\u6d77\u9f9f<\/span><\/span>\n<span class=\"line\"><span style=\"color: #90A4AE\">pen <\/span><span style=\"color: #39ADB5\">=<\/span><span style=\"color: #90A4AE\"> t<\/span><span style=\"color: #39ADB5\">.<\/span><span style=\"color: #6182B8\">Turtle<\/span><span style=\"color: #39ADB5\">()<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #90A4AE; font-style: italic\"># \u7ed8\u52363\u4e2a\u540c\u5fc3\u6b63\u516d\u8fb9\u5f62<\/span><\/span>\n<span class=\"line\"><span style=\"color: #90A4AE\">n <\/span><span style=\"color: #39ADB5\">=<\/span><span style=\"color: #90A4AE\"> <\/span><span style=\"color: #F76D47\">6<\/span><span style=\"color: #90A4AE\">  <\/span><span style=\"color: #90A4AE; font-style: italic\"># \u516d\u8fb9\u5f62<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #39ADB5; font-style: italic\">for<\/span><span style=\"color: #90A4AE\"> size <\/span><span style=\"color: #39ADB5; font-style: italic\">in<\/span><span style=\"color: #90A4AE\"> <\/span><span style=\"color: #39ADB5\">&#91;<\/span><span style=\"color: #F76D47\">50<\/span><span style=\"color: #39ADB5\">,<\/span><span style=\"color: #90A4AE\"> <\/span><span style=\"color: #F76D47\">80<\/span><span style=\"color: #39ADB5\">,<\/span><span style=\"color: #90A4AE\"> <\/span><span style=\"color: #F76D47\">110<\/span><span style=\"color: #39ADB5\">&#93;:<\/span><span style=\"color: #90A4AE\">  <\/span><span style=\"color: #90A4AE; font-style: italic\"># \u4e0d\u540c\u7684\u8fb9\u957f<\/span><\/span>\n<span class=\"line\"><span style=\"color: #90A4AE\">    pen<\/span><span style=\"color: #39ADB5\">.<\/span><span style=\"color: #6182B8\">penup<\/span><span style=\"color: #39ADB5\">()<\/span><\/span>\n<span class=\"line\"><span style=\"color: #90A4AE\">    pen<\/span><span style=\"color: #39ADB5\">.<\/span><span style=\"color: #6182B8\">goto<\/span><span style=\"color: #39ADB5\">(-<\/span><span style=\"color: #6182B8\">size<\/span><span style=\"color: #39ADB5\">\/<\/span><span style=\"color: #F76D47\">2<\/span><span style=\"color: #39ADB5\">,<\/span><span style=\"color: #6182B8\"> <\/span><span style=\"color: #39ADB5\">-<\/span><span style=\"color: #6182B8\">size<\/span><span style=\"color: #39ADB5\">\/<\/span><span style=\"color: #F76D47\">2<\/span><span style=\"color: #39ADB5\">)<\/span><span style=\"color: #90A4AE\">  <\/span><span style=\"color: #90A4AE; font-style: italic\"># \u8c03\u6574\u8d77\u59cb\u4f4d\u7f6e\u4f7f\u56fe\u5f62\u5c45\u4e2d<\/span><\/span>\n<span class=\"line\"><span style=\"color: #90A4AE\">    pen<\/span><span style=\"color: #39ADB5\">.<\/span><span style=\"color: #6182B8\">pendown<\/span><span style=\"color: #39ADB5\">()<\/span><\/span>\n<span class=\"line\"><span style=\"color: #90A4AE\">    <\/span><\/span>\n<span class=\"line\"><span style=\"color: #90A4AE\">    <\/span><span style=\"color: #39ADB5; font-style: italic\">for<\/span><span style=\"color: #90A4AE\"> i <\/span><span style=\"color: #39ADB5; font-style: italic\">in<\/span><span style=\"color: #90A4AE\"> <\/span><span style=\"color: #6182B8\">range<\/span><span style=\"color: #39ADB5\">(<\/span><span style=\"color: #6182B8\">n<\/span><span style=\"color: #39ADB5\">):<\/span><\/span>\n<span class=\"line\"><span style=\"color: #90A4AE\">        pen<\/span><span style=\"color: #39ADB5\">.<\/span><span style=\"color: #6182B8\">forward<\/span><span style=\"color: #39ADB5\">(<\/span><span style=\"color: #6182B8\">size<\/span><span style=\"color: #39ADB5\">)<\/span><\/span>\n<span class=\"line\"><span style=\"color: #90A4AE\">        pen<\/span><span style=\"color: #39ADB5\">.<\/span><span style=\"color: #6182B8\">right<\/span><span style=\"color: #39ADB5\">(<\/span><span style=\"color: #F76D47\">360<\/span><span style=\"color: #39ADB5\">\/<\/span><span style=\"color: #6182B8\">n<\/span><span style=\"color: #39ADB5\">)<\/span><\/span><\/code><\/pre><\/div>\n","protected":false},"excerpt":{"rendered":"","protected":false},"author":1,"featured_media":459,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[21,5],"tags":[],"class_list":["post-321","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-21","category-5"],"views":97,"_links":{"self":[{"href":"http:\/\/www.pyteam.cn\/index.php\/wp-json\/wp\/v2\/posts\/321","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=321"}],"version-history":[{"count":1,"href":"http:\/\/www.pyteam.cn\/index.php\/wp-json\/wp\/v2\/posts\/321\/revisions"}],"predecessor-version":[{"id":322,"href":"http:\/\/www.pyteam.cn\/index.php\/wp-json\/wp\/v2\/posts\/321\/revisions\/322"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/www.pyteam.cn\/index.php\/wp-json\/wp\/v2\/media\/459"}],"wp:attachment":[{"href":"http:\/\/www.pyteam.cn\/index.php\/wp-json\/wp\/v2\/media?parent=321"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.pyteam.cn\/index.php\/wp-json\/wp\/v2\/categories?post=321"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.pyteam.cn\/index.php\/wp-json\/wp\/v2\/tags?post=321"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}