{"id":927570,"date":"2024-12-26T16:14:45","date_gmt":"2024-12-26T08:14:45","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/927570.html"},"modified":"2024-12-26T16:14:48","modified_gmt":"2024-12-26T08:14:48","slug":"python%e5%a6%82%e4%bd%95%e4%bd%bf%e7%94%a8turtle","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/927570.html","title":{"rendered":"python\u5982\u4f55\u4f7f\u7528turtle"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/25063641\/6a61db3a-1cb6-4a3b-b63f-df0b21825f41.webp\" alt=\"python\u5982\u4f55\u4f7f\u7528turtle\" \/><\/p>\n<p><p> \u5728Python\u4e2d\uff0c<strong>\u4f7f\u7528turtle\u6a21\u5757\u53ef\u4ee5\u521b\u5efa\u7b80\u5355\u7684\u56fe\u5f62\u548c\u52a8\u753b<\/strong>\uff0c\u8fd9\u662f\u4e00\u4e2a\u975e\u5e38\u9002\u5408\u521d\u5b66\u8005\u7684\u5de5\u5177\uff0c\u56e0\u4e3a\u5b83\u7b80\u5355\u6613\u7528\u3001\u529f\u80fd\u76f4\u89c2\u3001\u80fd\u5feb\u901f\u5448\u73b0\u7ed3\u679c\u3002turtle\u6a21\u5757\u63d0\u4f9b\u4e86\u4e00\u53ea\u865a\u62df\u7684\u5c0f\u6d77\u9f9f\uff0c\u901a\u8fc7\u7b80\u5355\u7684\u547d\u4ee4\u63a7\u5236\u6d77\u9f9f\u7684\u79fb\u52a8\u6765\u7ed8\u5236\u56fe\u5f62\u3002\u8981\u4f7f\u7528turtle\u6a21\u5757\uff0c\u9996\u5148\u9700\u8981\u786e\u4fddPython\u73af\u5883\u4e2d\u5df2\u7ecf\u5b89\u88c5\u4e86\u8be5\u6a21\u5757\uff0c\u7136\u540e\u901a\u8fc7\u5bfc\u5165\u6a21\u5757\u5e76\u7f16\u5199\u4ee3\u7801\u6765\u5b9e\u73b0\u7ed8\u56fe\u3002\u4f8b\u5982\uff0c\u60a8\u53ef\u4ee5\u901a\u8fc7\u7b80\u5355\u7684\u6307\u4ee4\u63a7\u5236\u6d77\u9f9f\u524d\u8fdb\u3001\u540e\u9000\u3001\u5de6\u8f6c\u548c\u53f3\u8f6c\uff0c\u4ece\u800c\u7ed8\u5236\u51fa\u5404\u79cd\u5f62\u72b6\u548c\u56fe\u6848\u3002\u4e0b\u9762\uff0c\u6211\u5c06\u8be6\u7ec6\u4ecb\u7ecd\u5982\u4f55\u5728Python\u4e2d\u4f7f\u7528turtle\u6a21\u5757\u3002<\/p>\n<\/p>\n<p><p>\u4e00\u3001\u5b89\u88c5\u4e0e\u5bfc\u5165TURTLE\u6a21\u5757<\/p>\n<\/p>\n<p><p>\u5728\u5927\u591a\u6570Python\u53d1\u884c\u7248\u4e2d\uff0cturtle\u6a21\u5757\u90fd\u662f\u9884\u88c5\u7684\uff0c\u65e0\u9700\u989d\u5916\u5b89\u88c5\u3002\u5982\u679c\u4f60\u7684Python\u73af\u5883\u4e2d\u6ca1\u6709turtle\uff0c\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u6b65\u9aa4\u8fdb\u884c\u5b89\u88c5\uff1a<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u5b89\u88c5Python<\/strong>\uff1a\u786e\u4fdd\u4f60\u7684\u8ba1\u7b97\u673a\u4e0a\u5df2\u7ecf\u5b89\u88c5\u4e86Python\u3002\u53ef\u4ee5\u901a\u8fc7\u547d\u4ee4<code>python --version<\/code>\u6765\u68c0\u67e5Python\u7248\u672c\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u5b89\u88c5turtle<\/strong>\uff1a\u4f7f\u7528pip\u547d\u4ee4\u6765\u5b89\u88c5turtle\u6a21\u5757\u3002\u5982\u679c\u4f60\u7684Python\u7248\u672c\u4e2d\u6ca1\u6709\u81ea\u5e26turtle\uff0c\u53ef\u4ee5\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\u6765\u5b89\u88c5\uff1a<\/p>\n<\/p>\n<p><pre><code>pip install PythonTurtle<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u5bfc\u5165\u6a21\u5757<\/strong>\uff1a\u5728Python\u811a\u672c\u4e2d\u5bfc\u5165turtle\u6a21\u5757\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import turtle<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<\/ol>\n<p><p>\u5bfc\u5165\u540e\uff0c\u60a8\u4fbf\u53ef\u4ee5\u5f00\u59cb\u4f7f\u7528turtle\u5e93\u4e2d\u7684\u529f\u80fd\u8fdb\u884c\u7ed8\u56fe\u3002<\/p>\n<\/p>\n<p><p>\u4e8c\u3001TURTLE\u7684\u57fa\u672c\u4f7f\u7528<\/p>\n<\/p>\n<p><p>turtle\u6a21\u5757\u7684\u4f7f\u7528\u975e\u5e38\u76f4\u89c2\uff0c\u4e3b\u8981\u901a\u8fc7\u547d\u4ee4\u63a7\u5236&quot;\u6d77\u9f9f&quot;\u7684\u79fb\u52a8\u6765\u7ed8\u5236\u56fe\u5f62\u3002<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u521b\u5efa\u6d77\u9f9f\u5bf9\u8c61<\/strong>\uff1a\u5728\u4f7f\u7528turtle\u4e4b\u524d\uff0c\u6211\u4eec\u9700\u8981\u521b\u5efa\u4e00\u4e2a\u6d77\u9f9f\u5bf9\u8c61\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">my_turtle = turtle.Turtle()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u7ed8\u56fe\u7a97\u53e3<\/strong>\uff1aturtle\u7ed8\u56fe\u662f\u5728\u4e00\u4e2a\u7a97\u53e3\u4e2d\u8fdb\u884c\u7684\uff0c\u9ed8\u8ba4\u60c5\u51b5\u4e0b\u4f1a\u81ea\u52a8\u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u7ed8\u56fe\u7a97\u53e3\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u57fa\u672c\u547d\u4ee4<\/strong>\uff1a<\/p>\n<\/p>\n<ul>\n<li><strong>\u524d\u8fdb\u548c\u540e\u9000<\/strong>\uff1a\u4f7f\u7528<code>forward(distance)<\/code>\u548c<code>backward(distance)<\/code>\u63a7\u5236\u6d77\u9f9f\u524d\u8fdb\u6216\u540e\u9000\u6307\u5b9a\u7684\u50cf\u7d20\u6570\u3002\n<pre><code class=\"language-python\">my_turtle.forward(100)  # \u524d\u8fdb100\u50cf\u7d20<\/p>\n<p>my_turtle.backward(50)  # \u540e\u900050\u50cf\u7d20<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li><strong>\u8f6c\u5411<\/strong>\uff1a\u4f7f\u7528<code>right(angle)<\/code>\u548c<code>left(angle)<\/code>\u6765\u63a7\u5236\u6d77\u9f9f\u7684\u53f3\u8f6c\u6216\u5de6\u8f6c\uff0c\u5355\u4f4d\u4e3a\u5ea6\u6570\u3002\n<pre><code class=\"language-python\">my_turtle.right(90)  # \u53f3\u8f6c90\u5ea6<\/p>\n<p>my_turtle.left(45)   # \u5de6\u8f6c45\u5ea6<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><strong>\u753b\u7b14\u63a7\u5236<\/strong>\uff1a<\/p>\n<\/p>\n<ul>\n<li><strong>\u62ac\u7b14\u548c\u843d\u7b14<\/strong>\uff1a\u4f7f\u7528<code>penup()<\/code>\u548c<code>pendown()<\/code>\u6765\u63a7\u5236\u6d77\u9f9f\u62ac\u8d77\u6216\u843d\u4e0b\u753b\u7b14\u3002\u62ac\u7b14\u65f6\u79fb\u52a8\u4e0d\u7559\u4e0b\u75d5\u8ff9\u3002\n<pre><code class=\"language-python\">my_turtle.penup()    # \u62ac\u8d77\u753b\u7b14<\/p>\n<p>my_turtle.pendown()  # \u843d\u4e0b\u753b\u7b14<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li><strong>\u753b\u7b14\u989c\u8272\u548c\u7c97\u7ec6<\/strong>\uff1a\u4f7f\u7528<code>pencolor(color)<\/code>\u548c<code>pensize(size)<\/code>\u8bbe\u7f6e\u753b\u7b14\u989c\u8272\u548c\u7c97\u7ec6\u3002\n<pre><code class=\"language-python\">my_turtle.pencolor(&quot;blue&quot;)  # \u8bbe\u7f6e\u753b\u7b14\u989c\u8272\u4e3a\u84dd\u8272<\/p>\n<p>my_turtle.pensize(2)        # \u8bbe\u7f6e\u753b\u7b14\u7c97\u7ec6\u4e3a2\u50cf\u7d20<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><strong>\u6e05\u9664\u56fe\u5f62<\/strong>\uff1a<\/p>\n<\/p>\n<ul>\n<li><strong>\u6e05\u5c4f<\/strong>\uff1a\u4f7f\u7528<code>clear()<\/code>\u6e05\u9664\u6d77\u9f9f\u7ed8\u5236\u7684\u56fe\u5f62\uff0c\u4f46\u6d77\u9f9f\u4f4d\u7f6e\u548c\u72b6\u6001\u4e0d\u53d8\u3002<\/li>\n<li><strong>\u91cd\u7f6e<\/strong>\uff1a\u4f7f\u7528<code>reset()<\/code>\u91cd\u7f6e\u6d77\u9f9f\u548c\u7ed8\u56fe\u7a97\u53e3\u5230\u521d\u59cb\u72b6\u6001\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<p><p>\u4e09\u3001\u7ed8\u5236\u57fa\u672c\u56fe\u5f62<\/p>\n<\/p>\n<p><p>\u4f7f\u7528turtle\u6a21\u5757\uff0c\u6211\u4eec\u53ef\u4ee5\u7ed8\u5236\u5404\u79cd\u57fa\u672c\u56fe\u5f62\uff0c\u5982\u76f4\u7ebf\u3001\u77e9\u5f62\u3001\u5706\u5f62\u7b49\u3002<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u7ed8\u5236\u76f4\u7ebf<\/strong>\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import turtle<\/p>\n<p>my_turtle = turtle.Turtle()<\/p>\n<p>my_turtle.forward(100)  # \u7ed8\u5236\u4e00\u6761100\u50cf\u7d20\u7684\u76f4\u7ebf<\/p>\n<p>turtle.done()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u7ed8\u5236\u77e9\u5f62<\/strong>\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import turtle<\/p>\n<p>my_turtle = turtle.Turtle()<\/p>\n<p>for _ in range(4):<\/p>\n<p>    my_turtle.forward(100)  # \u6bcf\u6761\u8fb9\u957f100\u50cf\u7d20<\/p>\n<p>    my_turtle.right(90)     # \u53f3\u8f6c90\u5ea6<\/p>\n<p>turtle.done()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u7ed8\u5236\u5706\u5f62<\/strong>\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import turtle<\/p>\n<p>my_turtle = turtle.Turtle()<\/p>\n<p>my_turtle.circle(50)  # \u7ed8\u5236\u534a\u5f84\u4e3a50\u50cf\u7d20\u7684\u5706<\/p>\n<p>turtle.done()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<\/ol>\n<p><p>\u56db\u3001\u63d0\u9ad8TURTLE\u7ed8\u56fe\u7684\u590d\u6742\u5ea6<\/p>\n<\/p>\n<p><p>turtle\u6a21\u5757\u4e0d\u4ec5\u53ef\u4ee5\u7ed8\u5236\u7b80\u5355\u7684\u56fe\u5f62\uff0c\u8fd8\u53ef\u4ee5\u901a\u8fc7\u7f16\u5199\u5faa\u73af\u548c\u51fd\u6570\u6765\u7ed8\u5236\u590d\u6742\u7684\u56fe\u6848\u3002<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u4f7f\u7528\u5faa\u73af\u7ed8\u5236\u591a\u8fb9\u5f62<\/strong>\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import turtle<\/p>\n<p>my_turtle = turtle.Turtle()<\/p>\n<p>sides = 6  # \u8fb9\u6570<\/p>\n<p>length = 70  # \u8fb9\u957f<\/p>\n<p>angle = 360 \/ sides  # \u6bcf\u4e2a\u89d2\u7684\u5ea6\u6570<\/p>\n<p>for _ in range(sides):<\/p>\n<p>    my_turtle.forward(length)<\/p>\n<p>    my_turtle.right(angle)<\/p>\n<p>turtle.done()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u7ed8\u5236\u87ba\u65cb\u56fe\u6848<\/strong>\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import turtle<\/p>\n<p>my_turtle = turtle.Turtle()<\/p>\n<p>for i in range(100):<\/p>\n<p>    my_turtle.forward(i)<\/p>\n<p>    my_turtle.right(20)<\/p>\n<p>turtle.done()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u5b9a\u4e49\u51fd\u6570\u7ed8\u5236\u56fe\u6848<\/strong>\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import turtle<\/p>\n<p>def draw_star(turtle, size):<\/p>\n<p>    for _ in range(5):<\/p>\n<p>        turtle.forward(size)<\/p>\n<p>        turtle.right(144)  # \u4e94\u89d2\u661f\u7684\u89d2\u5ea6<\/p>\n<p>my_turtle = turtle.Turtle()<\/p>\n<p>draw_star(my_turtle, 100)<\/p>\n<p>turtle.done()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<\/ol>\n<p><p>\u4e94\u3001TURTLE\u6a21\u5757\u7684\u9ad8\u7ea7\u529f\u80fd<\/p>\n<\/p>\n<p><p>turtle\u6a21\u5757\u8fd8\u63d0\u4f9b\u4e86\u4e00\u4e9b\u9ad8\u7ea7\u529f\u80fd\uff0c\u5982\u8bbe\u7f6e\u80cc\u666f\u989c\u8272\u3001\u586b\u5145\u56fe\u5f62\u3001\u63a7\u5236\u901f\u5ea6\u7b49\u3002<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u8bbe\u7f6e\u80cc\u666f\u989c\u8272<\/strong>\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">turtle.bgcolor(&quot;lightblue&quot;)  # \u8bbe\u7f6e\u80cc\u666f\u989c\u8272\u4e3a\u6d45\u84dd\u8272<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u586b\u5145\u56fe\u5f62<\/strong>\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import turtle<\/p>\n<p>my_turtle = turtle.Turtle()<\/p>\n<p>my_turtle.fillcolor(&quot;red&quot;)  # \u8bbe\u7f6e\u586b\u5145\u989c\u8272<\/p>\n<p>my_turtle.begin_fill()  # \u5f00\u59cb\u586b\u5145<\/p>\n<p>for _ in range(4):<\/p>\n<p>    my_turtle.forward(100)<\/p>\n<p>    my_turtle.right(90)<\/p>\n<p>my_turtle.end_fill()  # \u7ed3\u675f\u586b\u5145<\/p>\n<p>turtle.done()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u8bbe\u7f6e\u901f\u5ea6<\/strong>\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">my_turtle.speed(1)  # \u901f\u5ea6\u8303\u56f4\u4ece1\u523010\uff0c1\u6700\u6162\uff0c10\u6700\u5feb<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u9690\u85cf\u548c\u663e\u793a\u6d77\u9f9f<\/strong>\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">my_turtle.hideturtle()  # \u9690\u85cf\u6d77\u9f9f<\/p>\n<p>my_turtle.showturtle()  # \u663e\u793a\u6d77\u9f9f<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<\/ol>\n<p><p>\u516d\u3001\u603b\u7ed3<\/p>\n<\/p>\n<p><p><strong>turtle\u6a21\u5757\u662f\u4e00\u4e2a\u5f3a\u5927\u4e14\u6613\u4e8e\u4f7f\u7528\u7684\u5de5\u5177\uff0c\u975e\u5e38\u9002\u5408\u7528\u4e8e\u6559\u5b66\u3001\u5b66\u4e60\u7f16\u7a0b\u57fa\u7840\u548c\u7b80\u5355\u7684\u56fe\u5f62\u7ed8\u5236<\/strong>\u3002\u901a\u8fc7\u7b80\u5355\u7684\u547d\u4ee4\u548c\u903b\u8f91\uff0c\u53ef\u4ee5\u521b\u5efa\u51fa\u4e30\u5bcc\u591a\u5f69\u7684\u56fe\u5f62\u548c\u52a8\u753b\u3002\u65e0\u8bba\u662f\u521d\u5b66\u8005\u8fd8\u662f\u7ecf\u9a8c\u4e30\u5bcc\u7684\u7a0b\u5e8f\u5458\uff0cturtle\u6a21\u5757\u90fd\u63d0\u4f9b\u4e86\u4e00\u4e2a\u6709\u8da3\u548c\u6709\u76ca\u7684\u65b9\u5f0f\u6765\u63a2\u7d22\u7f16\u7a0b\u7684\u4e50\u8da3\u3002\u901a\u8fc7\u4e0d\u65ad\u5730\u5b9e\u9a8c\u548c\u521b\u9020\uff0c\u60a8\u53ef\u4ee5\u5229\u7528turtle\u6a21\u5757\u5b9e\u73b0\u4ece\u7b80\u5355\u56fe\u5f62\u5230\u590d\u6742\u56fe\u6848\u7684\u8fc7\u6e21\uff0c\u751a\u81f3\u53ef\u4ee5\u7ed3\u5408\u5176\u4ed6Python\u6a21\u5757\u521b\u5efa\u4ea4\u4e92\u5f0f\u7684\u56fe\u5f62\u5e94\u7528\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u5982\u4f55\u5b89\u88c5Python\u7684Turtle\u6a21\u5757\uff1f<\/strong><br \/>Turtle\u6a21\u5757\u662fPython\u6807\u51c6\u5e93\u7684\u4e00\u90e8\u5206\uff0c\u56e0\u6b64\u5728\u5b89\u88c5Python\u65f6\u901a\u5e38\u4f1a\u81ea\u52a8\u5305\u542b\u5b83\u3002\u786e\u4fdd\u4f60\u7684Python\u7248\u672c\u4e3a3.x\uff08\u63a8\u8350\u4f7f\u7528Python 3.6\u53ca\u4ee5\u4e0a\u7248\u672c\uff09\u3002\u5982\u679c\u4f60\u5df2\u7ecf\u5b89\u88c5\u4e86Python\uff0c\u53ef\u4ee5\u76f4\u63a5\u5728\u4f60\u7684Python\u73af\u5883\u4e2d\u5bfc\u5165turtle\u6a21\u5757\uff0c\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u8fdb\u884c\u9a8c\u8bc1\uff1a  <\/p>\n<pre><code class=\"language-python\">import turtle\n<\/code><\/pre>\n<p>\u5982\u679c\u6ca1\u6709\u9519\u8bef\u4fe1\u606f\uff0c\u8bf4\u660eTurtle\u6a21\u5757\u5df2\u6210\u529f\u5b89\u88c5\u5e76\u53ef\u4ee5\u4f7f\u7528\u3002<\/p>\n<p><strong>Turtle\u6a21\u5757\u7684\u57fa\u672c\u7528\u6cd5\u662f\u4ec0\u4e48\uff1f<\/strong><br \/>Turtle\u6a21\u5757\u63d0\u4f9b\u4e86\u4e00\u79cd\u7b80\u5355\u7684\u65b9\u5f0f\u6765\u7ed8\u5236\u56fe\u5f62\u548c\u521b\u5efa\u52a8\u753b\u3002\u4f7f\u7528<code>turtle<\/code>\u6a21\u5757\u65f6\uff0c\u9996\u5148\u9700\u8981\u521b\u5efa\u4e00\u4e2aturtle\u5bf9\u8c61\uff0c\u7136\u540e\u4f7f\u7528\u5404\u79cd\u547d\u4ee4\u6765\u63a7\u5236\u5b83\u7684\u8fd0\u52a8\u548c\u7ed8\u56fe\u3002\u4f8b\u5982\uff0c\u4f7f\u7528<code>t.forward(100)<\/code>\u6765\u5411\u524d\u79fb\u52a8100\u4e2a\u5355\u4f4d\uff0c\u4f7f\u7528<code>t.right(90)<\/code>\u6765\u5411\u53f3\u8f6c90\u5ea6\u3002\u901a\u8fc7\u7ec4\u5408\u8fd9\u4e9b\u57fa\u672c\u547d\u4ee4\uff0c\u53ef\u4ee5\u521b\u5efa\u590d\u6742\u7684\u56fe\u5f62\u548c\u56fe\u6848\u3002<\/p>\n<p><strong>\u5982\u4f55\u5728Turtle\u7ed8\u56fe\u4e2d\u4f7f\u7528\u989c\u8272\u548c\u586b\u5145\uff1f<\/strong><br \/>Turtle\u6a21\u5757\u652f\u6301\u4e30\u5bcc\u7684\u989c\u8272\u548c\u586b\u5145\u9009\u9879\u3002\u4f60\u53ef\u4ee5\u4f7f\u7528<code>t.color(&#39;color_name&#39;)<\/code>\u6765\u8bbe\u7f6e\u753b\u7b14\u7684\u989c\u8272\uff0c\u5e76\u4f7f\u7528<code>t.fillcolor(&#39;color_name&#39;)<\/code>\u6765\u8bbe\u7f6e\u586b\u5145\u989c\u8272\u3002\u5728\u7ed8\u5236\u56fe\u5f62\u65f6\uff0c\u53ef\u4ee5\u4f7f\u7528<code>t.begin_fill()<\/code>\u548c<code>t.end_fill()<\/code>\u6765\u5b9e\u73b0\u586b\u5145\u6548\u679c\u3002\u4f8b\u5982\uff0c\u60f3\u8981\u7ed8\u5236\u4e00\u4e2a\u7ea2\u8272\u7684\u5706\u5f62\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u4ee3\u7801\uff1a  <\/p>\n<pre><code class=\"language-python\">import turtle\nt = turtle.Turtle()\nt.fillcolor(&#39;red&#39;)\nt.begin_fill()\nt.circle(50)\nt.end_fill()\n<\/code><\/pre>\n<p>\u8fd9\u6837\u5c31\u53ef\u4ee5\u521b\u5efa\u4e00\u4e2a\u586b\u5145\u7ea2\u8272\u7684\u5706\u5f62\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u5728Python\u4e2d\uff0c\u4f7f\u7528turtle\u6a21\u5757\u53ef\u4ee5\u521b\u5efa\u7b80\u5355\u7684\u56fe\u5f62\u548c\u52a8\u753b\uff0c\u8fd9\u662f\u4e00\u4e2a\u975e\u5e38\u9002\u5408\u521d\u5b66\u8005\u7684\u5de5\u5177\uff0c\u56e0\u4e3a\u5b83\u7b80\u5355\u6613\u7528\u3001 [&hellip;]","protected":false},"author":3,"featured_media":927576,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[37],"tags":[],"acf":[],"_links":{"self":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/927570"}],"collection":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/comments?post=927570"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/927570\/revisions"}],"predecessor-version":[{"id":927578,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/927570\/revisions\/927578"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/927576"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=927570"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=927570"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=927570"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}