{"id":1106046,"date":"2025-01-08T16:36:33","date_gmt":"2025-01-08T08:36:33","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/1106046.html"},"modified":"2025-01-08T16:36:36","modified_gmt":"2025-01-08T08:36:36","slug":"%e5%a6%82%e4%bd%95python%e7%94%bb%e4%b8%80%e4%b8%aa%e6%ad%a3%e6%96%b9%e5%bd%a2","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/1106046.html","title":{"rendered":"\u5982\u4f55python\u753b\u4e00\u4e2a\u6b63\u65b9\u5f62"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/25070654\/9e61e83c-39bb-426f-9609-e4c1c7fe5047.webp\" alt=\"\u5982\u4f55python\u753b\u4e00\u4e2a\u6b63\u65b9\u5f62\" \/><\/p>\n<p><p> <strong>\u4f7f\u7528Python\u753b\u4e00\u4e2a\u6b63\u65b9\u5f62\u7684\u65b9\u6cd5\u6709\u51e0\u79cd\uff1a\u5229\u7528Turtle\u6a21\u5757\u3001\u5229\u7528Matplotlib\u6a21\u5757\u3001\u7f16\u5199\u81ea\u5b9a\u4e49\u51fd\u6570\u3002<\/strong><\/p>\n<\/p>\n<p><p><strong>\u5229\u7528Turtle\u6a21\u5757\u662f\u6700\u5e38\u7528\u7684\u65b9\u6cd5\u4e4b\u4e00\uff0c\u56e0\u4e3a\u5b83\u7b80\u5355\u6613\u7528\u4e14\u9002\u5408\u521d\u5b66\u8005\u3002<\/strong><\/p>\n<\/p>\n<p><p>Turtle\u6a21\u5757\u662fPython\u6807\u51c6\u5e93\u4e2d\u7684\u4e00\u4e2a\u56fe\u5f62\u6a21\u5757\uff0c\u5b83\u63d0\u4f9b\u4e86\u4e00\u4e2a\u7b80\u5355\u7684\u65b9\u5f0f\u6765\u7ed8\u5236\u56fe\u5f62\u3002\u4f7f\u7528Turtle\u6a21\u5757\u7ed8\u5236\u4e00\u4e2a\u6b63\u65b9\u5f62\u7684\u6b65\u9aa4\u5982\u4e0b\uff1a<\/p>\n<\/p>\n<ol>\n<li>\u5bfc\u5165Turtle\u6a21\u5757\u3002<\/li>\n<li>\u521b\u5efa\u4e00\u4e2aTurtle\u5bf9\u8c61\u3002<\/li>\n<li>\u4f7f\u7528Turtle\u5bf9\u8c61\u7684\u7ed8\u56fe\u65b9\u6cd5\u6765\u753b\u6b63\u65b9\u5f62\u3002<\/li>\n<\/ol>\n<p><p>\u4e0b\u9762\u5c06\u8be6\u7ec6\u4ecb\u7ecd\u5982\u4f55\u4f7f\u7528Turtle\u6a21\u5757\u6765\u7ed8\u5236\u6b63\u65b9\u5f62\uff0c\u5e76\u63d0\u4f9b\u5176\u4ed6\u4e24\u79cd\u65b9\u6cd5\u7684\u793a\u4f8b\u3002<\/p>\n<\/p>\n<p><h3>\u4e00\u3001\u5229\u7528Turtle\u6a21\u5757\u7ed8\u5236\u6b63\u65b9\u5f62<\/h3>\n<\/p>\n<p><p>Turtle\u6a21\u5757\u662fPython\u4e2d\u4e00\u4e2a\u975e\u5e38\u6709\u7528\u7684\u7ed8\u56fe\u5de5\u5177\uff0c\u7279\u522b\u9002\u5408\u7528\u6765\u6559\u5b69\u5b50\u4eec\u7f16\u7a0b\u548c\u6570\u5b66\u56fe\u5f62\u3002\u4ee5\u4e0b\u662f\u4e00\u4e2a\u7b80\u5355\u7684\u793a\u4f8b\uff0c\u5c55\u793a\u5982\u4f55\u4f7f\u7528Turtle\u6a21\u5757\u7ed8\u5236\u4e00\u4e2a\u6b63\u65b9\u5f62\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import turtle<\/p>\n<h2><strong>\u521b\u5efa\u753b\u5e03<\/strong><\/h2>\n<p>window = turtle.Screen()<\/p>\n<p>window.bgcolor(&quot;white&quot;)<\/p>\n<h2><strong>\u521b\u5efa\u4e00\u4e2aTurtle\u5bf9\u8c61<\/strong><\/h2>\n<p>square_turtle = turtle.Turtle()<\/p>\n<p>square_turtle.color(&quot;black&quot;)<\/p>\n<p>square_turtle.speed(1)<\/p>\n<h2><strong>\u753b\u6b63\u65b9\u5f62<\/strong><\/h2>\n<p>for _ in range(4):<\/p>\n<p>    square_turtle.forward(100)  # \u5411\u524d\u79fb\u52a8100\u50cf\u7d20<\/p>\n<p>    square_turtle.right(90)     # \u5411\u53f3\u8f6c90\u5ea6<\/p>\n<h2><strong>\u5b8c\u6210\u7ed8\u56fe<\/strong><\/h2>\n<p>turtle.done()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u793a\u4f8b\u4e2d\uff0c\u6211\u4eec\u9996\u5148\u5bfc\u5165\u4e86Turtle\u6a21\u5757\uff0c\u7136\u540e\u521b\u5efa\u4e86\u4e00\u4e2a\u753b\u5e03\u548c\u4e00\u4e2aTurtle\u5bf9\u8c61\u3002\u63a5\u7740\uff0c\u4f7f\u7528\u4e00\u4e2a<code>for<\/code>\u5faa\u73af\u8ba9Turtle\u5bf9\u8c61\u5411\u524d\u79fb\u52a8100\u50cf\u7d20\uff0c\u5e76\u5411\u53f3\u8f6c90\u5ea6\uff0c\u8fd9\u4e2a\u8fc7\u7a0b\u91cd\u590d4\u6b21\u4ee5\u7ed8\u5236\u51fa\u4e00\u4e2a\u6b63\u65b9\u5f62\u3002<\/p>\n<\/p>\n<p><h3>\u4e8c\u3001\u5229\u7528Matplotlib\u6a21\u5757\u7ed8\u5236\u6b63\u65b9\u5f62<\/h3>\n<\/p>\n<p><p>Matplotlib\u662f\u4e00\u4e2a\u5f3a\u5927\u7684\u7ed8\u56fe\u5e93\uff0c\u901a\u5e38\u7528\u4e8e\u6570\u636e\u53ef\u89c6\u5316\u3002\u867d\u7136\u5b83\u4e3b\u8981\u7528\u4e8e\u7ed8\u5236\u56fe\u8868\uff0c\u4f46\u4e5f\u53ef\u4ee5\u7528\u6765\u7ed8\u5236\u7b80\u5355\u7684\u56fe\u5f62\uff0c\u4f8b\u5982\u6b63\u65b9\u5f62\u3002\u4ee5\u4e0b\u662f\u4f7f\u7528Matplotlib\u7ed8\u5236\u6b63\u65b9\u5f62\u7684\u793a\u4f8b\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import matplotlib.pyplot as plt<\/p>\n<h2><strong>\u5b9a\u4e49\u6b63\u65b9\u5f62\u7684\u9876\u70b9<\/strong><\/h2>\n<p>square = plt.Polygon(((0, 0), (1, 0), (1, 1), (0, 1)), closed=True, edgecolor=&#39;black&#39;)<\/p>\n<h2><strong>\u521b\u5efa\u56fe\u5f62\u548c\u5b50\u56fe<\/strong><\/h2>\n<p>fig, ax = plt.subplots()<\/p>\n<p>ax.add_patch(square)<\/p>\n<h2><strong>\u8bbe\u7f6e\u8f74\u7684\u8303\u56f4<\/strong><\/h2>\n<p>ax.set_xlim(-1, 2)<\/p>\n<p>ax.set_ylim(-1, 2)<\/p>\n<h2><strong>\u663e\u793a\u56fe\u5f62<\/strong><\/h2>\n<p>plt.gca().set_aspect(&#39;equal&#39;, adjustable=&#39;box&#39;)<\/p>\n<p>plt.grid(True)<\/p>\n<p>plt.show()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u793a\u4f8b\u4e2d\uff0c\u6211\u4eec\u4f7f\u7528\u4e86Matplotlib\u7684<code>Polygon<\/code>\u7c7b\u6765\u5b9a\u4e49\u6b63\u65b9\u5f62\u7684\u9876\u70b9\uff0c\u7136\u540e\u5c06\u5176\u6dfb\u52a0\u5230\u56fe\u5f62\u4e2d\u3002\u6700\u540e\uff0c\u901a\u8fc7\u8bbe\u7f6e\u8f74\u7684\u8303\u56f4\u548c\u663e\u793a\u56fe\u5f62\u6765\u5b8c\u6210\u7ed8\u5236\u3002<\/p>\n<\/p>\n<p><h3>\u4e09\u3001\u7f16\u5199\u81ea\u5b9a\u4e49\u51fd\u6570\u7ed8\u5236\u6b63\u65b9\u5f62<\/h3>\n<\/p>\n<p><p>\u5982\u679c\u4e0d\u60f3\u4f9d\u8d56\u4efb\u4f55\u5916\u90e8\u5e93\uff0c\u53ef\u4ee5\u7f16\u5199\u81ea\u5b9a\u4e49\u51fd\u6570\u5728\u63a7\u5236\u53f0\u4e2d\u7ed8\u5236\u4e00\u4e2a\u7b80\u5355\u7684\u6b63\u65b9\u5f62\u3002\u4ee5\u4e0b\u662f\u4e00\u4e2a\u793a\u4f8b\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">def draw_square(size):<\/p>\n<p>    for i in range(size):<\/p>\n<p>        for j in range(size):<\/p>\n<p>            print(&#39;*&#39;, end=&#39; &#39;)<\/p>\n<p>        print()<\/p>\n<h2><strong>\u8c03\u7528\u51fd\u6570\u7ed8\u5236\u6b63\u65b9\u5f62<\/strong><\/h2>\n<p>draw_square(5)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u793a\u4f8b\u4e2d\uff0c\u6211\u4eec\u5b9a\u4e49\u4e86\u4e00\u4e2a\u540d\u4e3a<code>draw_square<\/code>\u7684\u51fd\u6570\uff0c\u5b83\u63a5\u53d7\u4e00\u4e2a\u53c2\u6570<code>size<\/code>\uff0c\u8868\u793a\u6b63\u65b9\u5f62\u7684\u8fb9\u957f\u3002\u51fd\u6570\u4f7f\u7528\u5d4c\u5957\u7684<code>for<\/code>\u5faa\u73af\u5728\u63a7\u5236\u53f0\u4e2d\u7ed8\u5236\u6b63\u65b9\u5f62\u3002<\/p>\n<\/p>\n<p><h3>\u56db\u3001Turtle\u6a21\u5757\u7684\u9ad8\u7ea7\u7528\u6cd5<\/h3>\n<\/p>\n<p><p>\u9664\u4e86\u57fa\u672c\u7684\u7ed8\u56fe\u65b9\u6cd5\uff0cTurtle\u6a21\u5757\u8fd8\u63d0\u4f9b\u4e86\u8bb8\u591a\u9ad8\u7ea7\u529f\u80fd\uff0c\u4f8b\u5982\u8bbe\u7f6e\u989c\u8272\u3001\u586b\u5145\u5f62\u72b6\u3001\u7ed8\u5236\u590d\u6742\u56fe\u5f62\u7b49\u3002\u4ee5\u4e0b\u662f\u4e00\u4e2a\u793a\u4f8b\uff0c\u5c55\u793a\u5982\u4f55\u4f7f\u7528Turtle\u6a21\u5757\u7ed8\u5236\u4e00\u4e2a\u5e26\u6709\u586b\u5145\u989c\u8272\u7684\u6b63\u65b9\u5f62\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import turtle<\/p>\n<h2><strong>\u521b\u5efa\u753b\u5e03<\/strong><\/h2>\n<p>window = turtle.Screen()<\/p>\n<p>window.bgcolor(&quot;white&quot;)<\/p>\n<h2><strong>\u521b\u5efa\u4e00\u4e2aTurtle\u5bf9\u8c61<\/strong><\/h2>\n<p>square_turtle = turtle.Turtle()<\/p>\n<p>square_turtle.color(&quot;blue&quot;)<\/p>\n<p>square_turtle.speed(1)<\/p>\n<h2><strong>\u5f00\u59cb\u586b\u5145<\/strong><\/h2>\n<p>square_turtle.begin_fill()<\/p>\n<h2><strong>\u753b\u6b63\u65b9\u5f62<\/strong><\/h2>\n<p>for _ in range(4):<\/p>\n<p>    square_turtle.forward(100)<\/p>\n<p>    square_turtle.right(90)<\/p>\n<h2><strong>\u7ed3\u675f\u586b\u5145<\/strong><\/h2>\n<p>square_turtle.end_fill()<\/p>\n<h2><strong>\u5b8c\u6210\u7ed8\u56fe<\/strong><\/h2>\n<p>turtle.done()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u793a\u4f8b\u4e2d\uff0c\u6211\u4eec\u4f7f\u7528\u4e86<code>begin_fill<\/code>\u548c<code>end_fill<\/code>\u65b9\u6cd5\u6765\u7ed8\u5236\u4e00\u4e2a\u5e26\u6709\u586b\u5145\u989c\u8272\u7684\u6b63\u65b9\u5f62\u3002Turtle\u5bf9\u8c61\u7684<code>color<\/code>\u65b9\u6cd5\u7528\u6765\u8bbe\u7f6e\u7ed8\u56fe\u7684\u989c\u8272\u3002<\/p>\n<\/p>\n<p><h3>\u4e94\u3001\u5229\u7528Tkinter\u6a21\u5757\u7ed8\u5236\u6b63\u65b9\u5f62<\/h3>\n<\/p>\n<p><p>Tkinter\u662fPython\u7684\u6807\u51c6GUI\u5e93\uff0c\u53ef\u4ee5\u7528\u4e8e\u521b\u5efa\u56fe\u5f62\u7528\u6237\u754c\u9762\u3002\u4ee5\u4e0b\u662f\u4f7f\u7528Tkinter\u7ed8\u5236\u4e00\u4e2a\u6b63\u65b9\u5f62\u7684\u793a\u4f8b\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import tkinter as tk<\/p>\n<h2><strong>\u521b\u5efa\u4e3b\u7a97\u53e3<\/strong><\/h2>\n<p>root = tk.Tk()<\/p>\n<p>root.title(&quot;\u6b63\u65b9\u5f62\u7ed8\u5236&quot;)<\/p>\n<h2><strong>\u521b\u5efa\u753b\u5e03<\/strong><\/h2>\n<p>canvas = tk.Canvas(root, width=200, height=200)<\/p>\n<p>canvas.pack()<\/p>\n<h2><strong>\u7ed8\u5236\u6b63\u65b9\u5f62<\/strong><\/h2>\n<p>canvas.create_rectangle(50, 50, 150, 150, outline=&quot;black&quot;)<\/p>\n<h2><strong>\u8fd0\u884c\u4e3b\u5faa\u73af<\/strong><\/h2>\n<p>root.m<a href=\"https:\/\/docs.pingcode.com\/blog\/59162.html\" target=\"_blank\">AI<\/a>nloop()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u793a\u4f8b\u4e2d\uff0c\u6211\u4eec\u521b\u5efa\u4e86\u4e00\u4e2aTkinter\u4e3b\u7a97\u53e3\u548c\u4e00\u4e2a\u753b\u5e03\uff0c\u7136\u540e\u4f7f\u7528<code>create_rectangle<\/code>\u65b9\u6cd5\u7ed8\u5236\u4e86\u4e00\u4e2a\u6b63\u65b9\u5f62\u3002<\/p>\n<\/p>\n<p><h3>\u516d\u3001\u6bd4\u8f83\u4e0d\u540c\u65b9\u6cd5\u7684\u4f18\u7f3a\u70b9<\/h3>\n<\/p>\n<ol>\n<li><strong>Turtle\u6a21\u5757<\/strong>\uff1a\u7b80\u5355\u6613\u7528\uff0c\u9002\u5408\u521d\u5b66\u8005\u548c\u6559\u80b2\u7528\u9014\uff0c\u4f46\u7ed8\u56fe\u901f\u5ea6\u8f83\u6162\uff0c\u9002\u5408\u7ed8\u5236\u7b80\u5355\u56fe\u5f62\u3002<\/li>\n<li><strong>Matplotlib\u6a21\u5757<\/strong>\uff1a\u529f\u80fd\u5f3a\u5927\uff0c\u9002\u5408\u6570\u636e\u53ef\u89c6\u5316\u548c\u7ed8\u5236\u590d\u6742\u56fe\u5f62\uff0c\u4f46\u5b66\u4e60\u66f2\u7ebf\u8f83\u9661\u3002<\/li>\n<li><strong>\u81ea\u5b9a\u4e49\u51fd\u6570<\/strong>\uff1a\u65e0\u9700\u5916\u90e8\u5e93\uff0c\u9002\u5408\u5728\u63a7\u5236\u53f0\u4e2d\u7ed8\u5236\u7b80\u5355\u56fe\u5f62\uff0c\u4f46\u529f\u80fd\u6709\u9650\uff0c\u65e0\u6cd5\u7ed8\u5236\u590d\u6742\u56fe\u5f62\u3002<\/li>\n<li><strong>Tkinter\u6a21\u5757<\/strong>\uff1a\u9002\u5408\u521b\u5efa\u56fe\u5f62\u7528\u6237\u754c\u9762\uff0c\u53ef\u4ee5\u7ed8\u5236\u7b80\u5355\u56fe\u5f62\uff0c\u4f46\u4e0d\u5982Turtle\u548cMatplotlib\u7075\u6d3b\u3002<\/li>\n<\/ol>\n<p><h3>\u4e03\u3001\u9009\u62e9\u5408\u9002\u7684\u65b9\u6cd5<\/h3>\n<\/p>\n<p><p>\u6839\u636e\u5177\u4f53\u9700\u6c42\u9009\u62e9\u5408\u9002\u7684\u65b9\u6cd5\u3002\u5982\u679c\u9700\u8981\u7b80\u5355\u7684\u56fe\u5f62\u7ed8\u5236\uff0c<strong>Turtle\u6a21\u5757<\/strong>\u662f\u4e00\u4e2a\u4e0d\u9519\u7684\u9009\u62e9\u3002\u5982\u679c\u9700\u8981\u8fdb\u884c\u6570\u636e\u53ef\u89c6\u5316\u6216\u7ed8\u5236\u590d\u6742\u56fe\u5f62\uff0c<strong>Matplotlib\u6a21\u5757<\/strong>\u66f4\u4e3a\u5408\u9002\u3002\u5982\u679c\u4ec5\u9700\u8981\u5728\u63a7\u5236\u53f0\u4e2d\u7ed8\u5236\u7b80\u5355\u56fe\u5f62\uff0c\u53ef\u4ee5\u7f16\u5199<strong>\u81ea\u5b9a\u4e49\u51fd\u6570<\/strong>\u3002\u5982\u679c\u9700\u8981\u521b\u5efa\u56fe\u5f62\u7528\u6237\u754c\u9762\uff0c\u53ef\u4ee5\u8003\u8651\u4f7f\u7528<strong>Tkinter\u6a21\u5757<\/strong>\u3002<\/p>\n<\/p>\n<p><h3>\u516b\u3001\u603b\u7ed3<\/h3>\n<\/p>\n<p><p>Python\u63d0\u4f9b\u4e86\u591a\u79cd\u7ed8\u5236\u6b63\u65b9\u5f62\u7684\u65b9\u6cd5\uff0c\u5305\u62ecTurtle\u6a21\u5757\u3001Matplotlib\u6a21\u5757\u3001\u81ea\u5b9a\u4e49\u51fd\u6570\u548cTkinter\u6a21\u5757\u3002\u6bcf\u79cd\u65b9\u6cd5\u90fd\u6709\u5176\u4f18\u7f3a\u70b9\uff0c\u9002\u7528\u4e8e\u4e0d\u540c\u7684\u573a\u666f\u3002\u901a\u8fc7\u672c\u6587\u7684\u4ecb\u7ecd\uff0c\u8bfb\u8005\u53ef\u4ee5\u6839\u636e\u5177\u4f53\u9700\u6c42\u9009\u62e9\u5408\u9002\u7684\u65b9\u6cd5\u6765\u7ed8\u5236\u6b63\u65b9\u5f62\u3002\u5e0c\u671b\u672c\u6587\u5bf9\u60a8\u5b66\u4e60Python\u56fe\u5f62\u7ed8\u5236\u6709\u6240\u5e2e\u52a9\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u5982\u4f55\u4f7f\u7528Python\u7ed8\u5236\u6b63\u65b9\u5f62\u7684\u57fa\u672c\u6b65\u9aa4\u662f\u4ec0\u4e48\uff1f<\/strong><br \/>\u5728Python\u4e2d\u7ed8\u5236\u6b63\u65b9\u5f62\u901a\u5e38\u53ef\u4ee5\u901a\u8fc7\u4f7f\u7528\u56fe\u5f62\u5e93\u5982Turtle\u6216Matplotlib\u6765\u5b9e\u73b0\u3002\u4ee5Turtle\u4e3a\u4f8b\uff0c\u60a8\u53ef\u4ee5\u4f7f\u7528Turtle\u5e93\u7684<code>forward()<\/code>\u548c<code>right()<\/code>\u65b9\u6cd5\u6765\u63a7\u5236\u753b\u7b14\u7684\u79fb\u52a8\u3002\u4f8b\u5982\uff0c\u60a8\u53ef\u4ee5\u5148\u79fb\u52a8\u753b\u7b14\u4e00\u5b9a\u7684\u8ddd\u79bb\uff0c\u7136\u540e\u8f6c90\u5ea6\uff0c\u518d\u91cd\u590d\u8fd9\u4e2a\u8fc7\u7a0b\u56db\u6b21\uff0c\u4fbf\u53ef\u4ee5\u7ed8\u5236\u4e00\u4e2a\u6b63\u65b9\u5f62\u3002<\/p>\n<p><strong>Turtle\u5e93\u4e0eMatplotlib\u5e93\u7ed8\u5236\u6b63\u65b9\u5f62\u6709\u4ec0\u4e48\u4e0d\u540c\uff1f<\/strong><br \/>Turtle\u5e93\u4e3b\u8981\u7528\u4e8e\u7b80\u5355\u7684\u56fe\u5f62\u7ed8\u5236\uff0c\u9002\u5408\u521d\u5b66\u8005\u548c\u6559\u80b2\u7528\u9014\uff0c\u80fd\u591f\u4ee5\u52a8\u753b\u7684\u65b9\u5f0f\u5c55\u793a\u7ed8\u5236\u8fc7\u7a0b\u3002\u800cMatplotlib\u5219\u66f4\u9002\u5408\u6570\u636e\u53ef\u89c6\u5316\uff0c\u5b83\u53ef\u4ee5\u7ed8\u5236\u66f4\u590d\u6742\u7684\u56fe\u5f62\u5e76\u8fdb\u884c\u6570\u636e\u5206\u6790\u3002\u5982\u679c\u60a8\u7684\u76ee\u6807\u662f\u521b\u5efa\u53ef\u89c6\u5316\u56fe\u5f62\uff0cMatplotlib\u53ef\u80fd\u66f4\u5408\u9002\uff1b\u5982\u679c\u4ec5\u4ec5\u662f\u5b66\u4e60\u7f16\u7a0b\u548c\u56fe\u5f62\u57fa\u7840\uff0cTurtle\u5e93\u4f1a\u66f4\u7b80\u5355\u6613\u4e0a\u624b\u3002<\/p>\n<p><strong>\u5728\u7ed8\u5236\u6b63\u65b9\u5f62\u65f6\uff0c\u5982\u4f55\u8bbe\u7f6e\u4e0d\u540c\u7684\u989c\u8272\u548c\u8fb9\u6846\u6837\u5f0f\uff1f<\/strong><br \/>\u5728Turtle\u5e93\u4e2d\uff0c\u60a8\u53ef\u4ee5\u4f7f\u7528<code>fillcolor()<\/code>\u548c<code>begin_fill()<\/code>\u3001<code>end_fill()<\/code>\u65b9\u6cd5\u6765\u8bbe\u7f6e\u586b\u5145\u989c\u8272\u3002\u6b64\u5916\uff0c\u53ef\u4ee5\u4f7f\u7528<code>pensize()<\/code>\u65b9\u6cd5\u6765\u6539\u53d8\u8fb9\u6846\u7684\u539a\u5ea6\u3002Matplotlib\u540c\u6837\u5141\u8bb8\u60a8\u901a\u8fc7<code>color<\/code>\u53c2\u6570\u8bbe\u7f6e\u989c\u8272\uff0c\u901a\u8fc7<code>linewidth<\/code>\u53c2\u6570\u8c03\u6574\u8fb9\u6846\u6837\u5f0f\u3002\u65e0\u8bba\u4f7f\u7528\u54ea\u79cd\u5e93\uff0c\u4e30\u5bcc\u7684\u989c\u8272\u548c\u6837\u5f0f\u8bbe\u7f6e\u90fd\u80fd\u591f\u8ba9\u60a8\u7684\u6b63\u65b9\u5f62\u66f4\u52a0\u7f8e\u89c2\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u4f7f\u7528Python\u753b\u4e00\u4e2a\u6b63\u65b9\u5f62\u7684\u65b9\u6cd5\u6709\u51e0\u79cd\uff1a\u5229\u7528Turtle\u6a21\u5757\u3001\u5229\u7528Matplotlib\u6a21\u5757\u3001\u7f16\u5199\u81ea\u5b9a\u4e49\u51fd\u6570\u3002 [&hellip;]","protected":false},"author":3,"featured_media":1106052,"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\/1106046"}],"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=1106046"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1106046\/revisions"}],"predecessor-version":[{"id":1106054,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1106046\/revisions\/1106054"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/1106052"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=1106046"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=1106046"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=1106046"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}