{"id":205030,"date":"2025-05-29T10:52:51","date_gmt":"2025-05-29T02:52:51","guid":{"rendered":"https:\/\/server.hk\/cnblog\/205030\/"},"modified":"2025-05-29T10:52:51","modified_gmt":"2025-05-29T02:52:51","slug":"%e5%a6%82%e4%bd%95%e7%94%a8-python-turtle-%e5%ba%93%e7%bb%98%e5%88%b6%e4%b8%80%e4%b8%aa%e5%ae%8c%e7%be%8e%e7%9a%84%e5%85%ab%e8%a7%92%e5%bd%a2%ef%bc%9f","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/205030\/","title":{"rendered":"\u5982\u4f55\u7528 Python turtle \u5e93\u7ed8\u5236\u4e00\u4e2a\u5b8c\u7f8e\u7684\u516b\u89d2\u5f62\uff1f"},"content":{"rendered":"<p><b><\/b>     <\/p>\n<h1>\u5982\u4f55\u7528 Python turtle \u5e93\u7ed8\u5236\u4e00\u4e2a\u5b8c\u7f8e\u7684\u516b\u89d2\u5f62\uff1f<\/h1>\n<p>\u672c\u7bc7\u6587\u7ae0\u4e3b\u8981\u662f\u7ed3\u5408\u6211\u4e4b\u524d\u9762\u8bd5\u7684\u5404\u79cd\u7ecf\u5386\u548c\u5b9e\u6218\u5f00\u53d1\u4e2d\u9047\u5230\u7684\u95ee\u9898\u89e3\u51b3\u7ecf\u9a8c\u6574\u7406\u7684\uff0c\u5e0c\u671b\u8fd9\u7bc7\u300a\u5982\u4f55\u7528 Python turtle \u5e93\u7ed8\u5236\u4e00\u4e2a\u5b8c\u7f8e\u7684\u516b\u89d2\u5f62\uff1f\u300b\u5bf9\u4f60\u6709\u5f88\u5927\u5e2e\u52a9\uff01\u6b22\u8fce\u6536\u85cf\uff0c\u5206\u4eab\u7ed9\u66f4\u591a\u7684\u9700\u8981\u7684\u670b\u53cb\u5b66\u4e60~<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.17golang.com\/uploads\/20241121\/1732200887673f49b73042e.jpg\" class=\"aligncenter\"><\/p>\n<p><strong>\u4f7f\u7528 python turtle \u7ed8\u5236\u516b\u89d2\u5f62<\/strong><\/p>\n<p>\u867d\u7136 circle() \u51fd\u6570\u53ef\u4ee5\u7528\u6765\u7ed8\u5236\u5706\u5f62\uff0c\u4f46\u5bf9\u4e8e\u7ed8\u5236\u591a\u8fb9\u5f62\u6765\u8bf4\u5374\u4e0d\u662f\u7406\u60f3\u7684\u9009\u62e9\u3002\u90a3\u4e48\uff0c\u5982\u4f55\u7528 python turtle \u5e93\u7ed8\u5236\u4e00\u4e2a\u5b8c\u7f8e\u7684\u516b\u89d2\u5f62\u5462\uff1f<\/p>\n<p>\u4e3a\u4e86\u89e3\u51b3\u8fd9\u4e2a\u95ee\u9898\uff0c\u6211\u4eec\u5fc5\u987b\u91c7\u53d6\u4e0d\u540c\u7684\u65b9\u6cd5\u3002\u4ee5\u4e0b\u662f\u5b9e\u73b0\u516b\u89d2\u5f62\u7ed8\u5236\u7684\u6b65\u9aa4\uff1a<\/p>\n<ol>\n<li>\n<p><strong>\u5bfc\u5165 turtle \u5e93\uff1a<\/strong><\/p>\n<pre>import turtle<\/pre>\n<\/li>\n<li>\n<p><strong>\u8bbe\u7f6e\u753b\u7b14\u5c5e\u6027\uff1a<\/strong><\/p>\n<pre>turtle.pensize(2)  # \u8bbe\u7f6e\u753b\u7b14\u5bbd\u5ea6\nturtle.color('red')  # \u8bbe\u7f6e\u753b\u7b14\u989c\u8272<\/pre>\n<\/li>\n<li>\n<p><strong>\u4f7f\u7528 for \u5faa\u73af\u7ed8\u5236\u516b\u4e2a\u8fb9\uff1a<\/strong><\/p>\n<pre>for i in range(8):\n turtle.forward(100)  # \u5411\u524d\u79fb\u52a8 100 \u4e2a\u5355\u4f4d\n turtle.right(45)     # \u53f3\u8f6c 45 \u5ea6<\/pre>\n<\/li>\n<li>\n<p><strong>\u4e3a\u4e86\u4f7f\u91cd\u53e0\u516b\u89d2\u5f62\u7684\u6548\u679c\u66f4\u52a0\u660e\u663e\uff0c\u9700\u8981\u65cb\u8f6c\u4e00\u5b9a\u89d2\u5ea6\uff1a<\/strong><\/p>\n<pre>turtle.right(22.5)  # \u53f3\u8f6c 22.5 \u5ea6<\/pre>\n<\/li>\n<li>\n<p><strong>\u4f7f\u7528\u53e6\u4e00\u4e2a for \u5faa\u73af\u7ed8\u5236\u5185\u90e8\u516b\u89d2\u5f62\uff1a<\/strong><\/p>\n<pre>for j in range(8):\n turtle.forward(58)  # \u5411\u524d\u79fb\u52a8 58 \u4e2a\u5355\u4f4d\n turtle.right(45)     # \u53f3\u8f6c 45 \u5ea6<\/pre>\n<\/li>\n<li>\n<p><strong>\u8c03\u7528 done() \u51fd\u6570\u4ee5\u5b8c\u6210\u7ed8\u5236\uff1a<\/strong><\/p>\n<pre>turtle.done()<\/pre>\n<\/li>\n<\/ol>\n<p>\u901a\u8fc7\u4f7f\u7528\u8fd9\u4e9b\u6b65\u9aa4\uff0c\u4f60\u53ef\u4ee5\u7ed8\u5236\u4e00\u4e2a\u5b8c\u7f8e\u7684\u516b\u89d2\u5f62\u3002\u8fd9\u4e0e\u4f7f\u7528 circle() \u51fd\u6570\u7ed8\u5236\u516b\u8fb9\u5f62\u4e0d\u540c\uff0c\u516b\u8fb9\u5f62\u662f\u4e00\u4e2a\u5177\u6709\u516b\u6761\u76f4\u8fb9\u7684\u591a\u8fb9\u5f62\uff0c\u800c\u516b\u89d2\u5f62\u662f\u4e00\u4e2a\u5177\u6709\u516b\u6761\u5f2f\u66f2\u8fb9\u7684\u5f62\u72b6\u3002<\/p>\n<p>\u4eca\u5929\u5173\u4e8e\u300a\u5982\u4f55\u7528 Python turtle \u5e93\u7ed8\u5236\u4e00\u4e2a\u5b8c\u7f8e\u7684\u516b\u89d2\u5f62\uff1f\u300b\u7684\u5185\u5bb9\u5c31\u4ecb\u7ecd\u5230\u8fd9\u91cc\u4e86\uff0c\u662f\u4e0d\u662f\u5b66\u8d77\u6765\u4e00\u76ee\u4e86\u7136\uff01\u60f3\u8981\u4e86\u89e3\u66f4\u591a\u5173\u4e8e\u7684\u5185\u5bb9\u8bf7\u5173\u6ce8\u516c\u4f17\u53f7\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5982\u4f55\u7528 Python turtl&#46;&#46;&#46;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4925],"tags":[],"class_list":["post-205030","post","type-post","status-publish","format-standard","hentry","category-4925"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/205030","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/comments?post=205030"}],"version-history":[{"count":0,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/205030\/revisions"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=205030"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=205030"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=205030"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}