{"id":319,"date":"2025-10-10T15:23:01","date_gmt":"2025-10-10T07:23:01","guid":{"rendered":"http:\/\/www.pyteam.cn\/?p=319"},"modified":"2025-10-10T15:23:02","modified_gmt":"2025-10-10T07:23:02","slug":"%e5%8f%82%e6%95%b0%e5%8c%96%e7%bb%98%e5%88%b6%e6%ad%a3%e5%a4%9a%e8%be%b9%e5%bd%a2-12-2","status":"publish","type":"post","link":"http:\/\/www.pyteam.cn\/index.php\/2025\/10\/10\/%e5%8f%82%e6%95%b0%e5%8c%96%e7%bb%98%e5%88%b6%e6%ad%a3%e5%a4%9a%e8%be%b9%e5%bd%a2-12-2\/","title":{"rendered":"\u53c2\u6570\u5316\u7ed8\u5236\u6b63\u591a\u8fb9\u5f62 12.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(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()\npen.speed(8)\npen.pensize(2)\n\n# \u83b7\u53d6\u7528\u6237\u8f93\u5165\nn = int(input(\"\u8bf7\u8f93\u5165\u6b63\u591a\u8fb9\u5f62\u7684\u8fb9\u6570\uff1a \"))\nlength = int(input(\"\u8bf7\u8f93\u5165\u8fb9\u957f\uff1a \"))\n\n# \u8ba1\u7b97\u5916\u89d2\u5ea6\u6570\uff08\u6d77\u9f9f\u6bcf\u6b21\u65cb\u8f6c\u7684\u89d2\u5ea6\uff09\nangle = 360 \/ n\n\n# \u4f7f\u7528\u5faa\u73af\u7ed8\u5236\u6b63\u591a\u8fb9\u5f62\nfor i in range(n):      # \u5faa\u73afn\u6b21\n    pen.forward(length) # \u753b\u4e00\u6761\u8fb9\n    pen.right(angle)    # \u65cb\u8f6c\u5916\u89d2\u5ea6\u6570\n\nt.done()<\/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 style=\"color: #90A4AE\">pen<\/span><span style=\"color: #39ADB5\">.<\/span><span style=\"color: #6182B8\">speed<\/span><span style=\"color: #39ADB5\">(<\/span><span style=\"color: #F76D47\">8<\/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\">pensize<\/span><span style=\"color: #39ADB5\">(<\/span><span style=\"color: #F76D47\">2<\/span><span style=\"color: #39ADB5\">)<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #90A4AE; font-style: italic\"># \u83b7\u53d6\u7528\u6237\u8f93\u5165<\/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: #E2931D\">int<\/span><span style=\"color: #39ADB5\">(<\/span><span style=\"color: #6182B8\">input<\/span><span style=\"color: #39ADB5\">(<\/span><span style=\"color: #39ADB5\">&quot;<\/span><span style=\"color: #91B859\">\u8bf7\u8f93\u5165\u6b63\u591a\u8fb9\u5f62\u7684\u8fb9\u6570\uff1a <\/span><span style=\"color: #39ADB5\">&quot;<\/span><span style=\"color: #39ADB5\">))<\/span><\/span>\n<span class=\"line\"><span style=\"color: #90A4AE\">length <\/span><span style=\"color: #39ADB5\">=<\/span><span style=\"color: #90A4AE\"> <\/span><span style=\"color: #E2931D\">int<\/span><span style=\"color: #39ADB5\">(<\/span><span style=\"color: #6182B8\">input<\/span><span style=\"color: #39ADB5\">(<\/span><span style=\"color: #39ADB5\">&quot;<\/span><span style=\"color: #91B859\">\u8bf7\u8f93\u5165\u8fb9\u957f\uff1a <\/span><span style=\"color: #39ADB5\">&quot;<\/span><span style=\"color: #39ADB5\">))<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #90A4AE; font-style: italic\"># \u8ba1\u7b97\u5916\u89d2\u5ea6\u6570\uff08\u6d77\u9f9f\u6bcf\u6b21\u65cb\u8f6c\u7684\u89d2\u5ea6\uff09<\/span><\/span>\n<span class=\"line\"><span style=\"color: #90A4AE\">angle <\/span><span style=\"color: #39ADB5\">=<\/span><span style=\"color: #90A4AE\"> <\/span><span style=\"color: #F76D47\">360<\/span><span style=\"color: #90A4AE\"> <\/span><span style=\"color: #39ADB5\">\/<\/span><span style=\"color: #90A4AE\"> n<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #90A4AE; font-style: italic\"># \u4f7f\u7528\u5faa\u73af\u7ed8\u5236\u6b63\u591a\u8fb9\u5f62<\/span><\/span>\n<span class=\"line\"><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 style=\"color: #90A4AE\">      <\/span><span style=\"color: #90A4AE; font-style: italic\"># \u5faa\u73afn\u6b21<\/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\">length<\/span><span style=\"color: #39ADB5\">)<\/span><span style=\"color: #90A4AE\"> <\/span><span style=\"color: #90A4AE; font-style: italic\"># \u753b\u4e00\u6761\u8fb9<\/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: #6182B8\">angle<\/span><span style=\"color: #39ADB5\">)<\/span><span style=\"color: #90A4AE\">    <\/span><span style=\"color: #90A4AE; font-style: italic\"># \u65cb\u8f6c\u5916\u89d2\u5ea6\u6570<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #90A4AE\">t<\/span><span style=\"color: #39ADB5\">.<\/span><span style=\"color: #6182B8\">done<\/span><span style=\"color: #39ADB5\">()<\/span><\/span><\/code><\/pre><\/div>\n","protected":false},"excerpt":{"rendered":"","protected":false},"author":1,"featured_media":106,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[21,5],"tags":[],"class_list":["post-319","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-21","category-5"],"views":83,"_links":{"self":[{"href":"http:\/\/www.pyteam.cn\/index.php\/wp-json\/wp\/v2\/posts\/319","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=319"}],"version-history":[{"count":1,"href":"http:\/\/www.pyteam.cn\/index.php\/wp-json\/wp\/v2\/posts\/319\/revisions"}],"predecessor-version":[{"id":320,"href":"http:\/\/www.pyteam.cn\/index.php\/wp-json\/wp\/v2\/posts\/319\/revisions\/320"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/www.pyteam.cn\/index.php\/wp-json\/wp\/v2\/media\/106"}],"wp:attachment":[{"href":"http:\/\/www.pyteam.cn\/index.php\/wp-json\/wp\/v2\/media?parent=319"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.pyteam.cn\/index.php\/wp-json\/wp\/v2\/categories?post=319"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.pyteam.cn\/index.php\/wp-json\/wp\/v2\/tags?post=319"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}