{"id":1011503,"date":"2024-12-27T11:30:26","date_gmt":"2024-12-27T03:30:26","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/1011503.html"},"modified":"2024-12-27T11:30:29","modified_gmt":"2024-12-27T03:30:29","slug":"python%e5%a6%82%e4%bd%95%e7%94%a8%e4%bb%a3%e7%a0%81%e7%94%bb%e5%9c%86","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/1011503.html","title":{"rendered":"python\u5982\u4f55\u7528\u4ee3\u7801\u753b\u5706"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/25085623\/55714f32-3bc1-4fd5-9d9a-36c745d8792e.webp\" alt=\"python\u5982\u4f55\u7528\u4ee3\u7801\u753b\u5706\" \/><\/p>\n<p><p> \u5728Python\u4e2d\uff0c\u53ef\u4ee5\u4f7f\u7528\u591a\u79cd\u65b9\u6cd5\u6765\u7ed8\u5236\u5706\u5f62\uff0c\u4e3b\u8981\u53d6\u51b3\u4e8e\u6240\u9009\u62e9\u7684\u5e93\u548c\u5de5\u5177\u3002<strong>\u4f7f\u7528Python\u7ed8\u5236\u5706\u5f62\u7684\u5e38\u7528\u65b9\u6cd5\u5305\u62ec\u4f7f\u7528Matplotlib\u3001Turtle\u548cPygame\u7b49\u5e93\u3002<\/strong> \u5176\u4e2d\uff0cMatplotlib\u662f\u4e00\u4e2a\u5f3a\u5927\u7684\u7ed8\u56fe\u5e93\uff0c\u9002\u5408\u751f\u6210\u9759\u6001\u56fe\u50cf\uff1bTurtle\u662f\u4e00\u4e2a\u7b80\u5355\u7684\u56fe\u5f62\u5e93\uff0c\u9002\u5408\u521d\u5b66\u8005\uff1b\u800cPygame\u5219\u662f\u4e00\u4e2a\u7528\u4e8e\u5f00\u53d1\u6e38\u620f\u7684\u5e93\uff0c\u5177\u6709\u66f4\u9ad8\u7684\u7075\u6d3b\u6027\u548c\u529f\u80fd\u6027\u3002\u4e0b\u9762\uff0c\u6211\u4eec\u5c06\u8be6\u7ec6\u4ecb\u7ecd\u5982\u4f55\u4f7f\u7528\u8fd9\u4e9b\u5e93\u6765\u7ed8\u5236\u5706\u5f62\u3002<\/p>\n<\/p>\n<p><p>\u4e00\u3001MATPLOTLIB\u7ed8\u5236\u5706\u5f62<\/p>\n<\/p>\n<p><p>Matplotlib\u662fPython\u4e2d\u6700\u6d41\u884c\u7684\u6570\u636e\u53ef\u89c6\u5316\u5e93\u4e4b\u4e00\uff0c\u5e38\u7528\u4e8e\u7ed8\u52362D\u56fe\u5f62\u3002\u4f7f\u7528Matplotlib\u7ed8\u5236\u5706\u5f62\u975e\u5e38\u7b80\u5355\uff0c\u901a\u5e38\u901a\u8fc7\u4f7f\u7528<code>pyplot<\/code>\u6a21\u5757\u7684<code>Circle<\/code>\u5bf9\u8c61\u6765\u5b9e\u73b0\u3002<\/p>\n<\/p>\n<ol>\n<li><strong>\u5b89\u88c5\u548c\u5bfc\u5165Matplotlib<\/strong><\/li>\n<\/ol>\n<p><p>\u5728\u4f7f\u7528Matplotlib\u4e4b\u524d\uff0c\u9996\u5148\u9700\u8981\u786e\u4fdd\u5df2\u5b89\u88c5\u8be5\u5e93\u3002\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u547d\u4ee4\u8fdb\u884c\u5b89\u88c5\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pip install matplotlib<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u53ef\u4ee5\u5728Python\u811a\u672c\u4e2d\u5bfc\u5165Matplotlib\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import matplotlib.pyplot as plt<\/p>\n<p>import numpy as np<\/p>\n<p><\/code><\/pre>\n<\/p>\n<ol start=\"2\">\n<li><strong>\u4f7f\u7528Circle\u5bf9\u8c61\u7ed8\u5236\u5706\u5f62<\/strong><\/li>\n<\/ol>\n<p><p>\u5728Matplotlib\u4e2d\uff0c\u53ef\u4ee5\u4f7f\u7528<code>Circle<\/code>\u5bf9\u8c61\u6765\u7ed8\u5236\u5706\u5f62\u3002\u4e0b\u9762\u662f\u4e00\u4e2a\u7b80\u5355\u7684\u793a\u4f8b\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import matplotlib.pyplot as plt<\/p>\n<h2><strong>\u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u56fe\u5f62<\/strong><\/h2>\n<p>fig, ax = plt.subplots()<\/p>\n<h2><strong>\u521b\u5efa\u4e00\u4e2a\u5706\u5f62\uff0c\u53c2\u6570\u4e3a\uff1a(\u5706\u5fc3x\u5750\u6807, \u5706\u5fc3y\u5750\u6807), \u534a\u5f84<\/strong><\/h2>\n<p>circle = plt.Circle((0.5, 0.5), 0.4, color=&#39;blue&#39;, fill=False)<\/p>\n<h2><strong>\u5c06\u5706\u5f62\u6dfb\u52a0\u5230\u56fe\u5f62\u4e2d<\/strong><\/h2>\n<p>ax.add_patch(circle)<\/p>\n<h2><strong>\u8bbe\u7f6e\u5750\u6807\u8f74\u7684\u8303\u56f4\u548c\u6bd4\u4f8b<\/strong><\/h2>\n<p>ax.set_xlim(0, 1)<\/p>\n<p>ax.set_ylim(0, 1)<\/p>\n<p>ax.set_aspect(&#39;equal&#39;, &#39;box&#39;)<\/p>\n<h2><strong>\u663e\u793a\u56fe\u5f62<\/strong><\/h2>\n<p>plt.show()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u4e0a\u8ff0\u4ee3\u7801\u4e2d\uff0c\u6211\u4eec\u521b\u5efa\u4e86\u4e00\u4e2a\u5706\u5fc3\u4f4d\u4e8e(0.5, 0.5)\uff0c\u534a\u5f84\u4e3a0.4\u7684\u5706\u5f62\u3002\u901a\u8fc7<code>ax.add_patch(circle)<\/code>\u5c06\u5706\u5f62\u6dfb\u52a0\u5230\u56fe\u5f62\u4e2d\uff0c\u5e76\u8bbe\u7f6e\u5750\u6807\u8f74\u7684\u8303\u56f4\u548c\u6bd4\u4f8b\u4ee5\u786e\u4fdd\u5706\u5f62\u7684\u6b63\u786e\u663e\u793a\u3002<\/p>\n<\/p>\n<ol start=\"3\">\n<li><strong>\u81ea\u5b9a\u4e49\u5706\u5f62\u7684\u5c5e\u6027<\/strong><\/li>\n<\/ol>\n<p><p>Matplotlib\u5141\u8bb8\u81ea\u5b9a\u4e49\u5706\u5f62\u7684\u5404\u79cd\u5c5e\u6027\uff0c\u4f8b\u5982\u989c\u8272\u3001\u586b\u5145\u7b49\u3002\u53ef\u4ee5\u901a\u8fc7<code>Circle<\/code>\u5bf9\u8c61\u7684\u53c2\u6570\u8fdb\u884c\u8bbe\u7f6e\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">circle = plt.Circle((0.5, 0.5), 0.4, color=&#39;green&#39;, fill=True, linestyle=&#39;dashed&#39;, linewidth=2, alpha=0.5)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u4e0a\u8ff0\u4ee3\u7801\u4e2d\uff0c\u6211\u4eec\u8bbe\u7f6e\u4e86\u5706\u5f62\u7684\u989c\u8272\u4e3a\u7eff\u8272\uff0c\u586b\u5145\u4e3aTrue\uff0c\u865a\u7ebf\u6837\u5f0f\uff0c\u7ebf\u5bbd\u4e3a2\uff0c\u5e76\u8bbe\u7f6e\u900f\u660e\u5ea6\u4e3a0.5\u3002<\/p>\n<\/p>\n<p><p>\u4e8c\u3001TURTLE\u7ed8\u5236\u5706\u5f62<\/p>\n<\/p>\n<p><p>Turtle\u662f\u4e00\u4e2a\u7b80\u5355\u7684\u56fe\u5f62\u5e93\uff0c\u9002\u5408\u521d\u5b66\u8005\u5b66\u4e60\u7f16\u7a0b\u548c\u7ed8\u56fe\u3002Turtle\u5e93\u901a\u8fc7\u6a21\u62df\u6d77\u9f9f\u5728\u5c4f\u5e55\u4e0a\u79fb\u52a8\u6765\u7ed8\u5236\u56fe\u5f62\u3002<\/p>\n<\/p>\n<ol>\n<li><strong>\u5bfc\u5165Turtle\u5e93<\/strong><\/li>\n<\/ol>\n<p><p>Turtle\u5e93\u662fPython\u7684\u6807\u51c6\u5e93\u4e4b\u4e00\uff0c\u56e0\u6b64\u65e0\u9700\u5b89\u88c5\uff0c\u53ef\u4ee5\u76f4\u63a5\u5bfc\u5165\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import turtle<\/p>\n<p><\/code><\/pre>\n<\/p>\n<ol start=\"2\">\n<li><strong>\u4f7f\u7528Turtle\u7ed8\u5236\u5706\u5f62<\/strong><\/li>\n<\/ol>\n<p><p>Turtle\u5e93\u4e2d\u6709\u4e00\u4e2a<code>circle<\/code>\u51fd\u6570\u7528\u4e8e\u7ed8\u5236\u5706\u5f62\u3002\u4e0b\u9762\u662f\u4e00\u4e2a\u7b80\u5355\u7684\u793a\u4f8b\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import turtle<\/p>\n<h2><strong>\u521b\u5efa\u4e00\u4e2aTurtle\u5bf9\u8c61<\/strong><\/h2>\n<p>t = turtle.Turtle()<\/p>\n<h2><strong>\u8bbe\u7f6e\u6d77\u9f9f\u7684\u901f\u5ea6<\/strong><\/h2>\n<p>t.speed(1)<\/p>\n<h2><strong>\u7ed8\u5236\u4e00\u4e2a\u534a\u5f84\u4e3a100\u7684\u5706\u5f62<\/strong><\/h2>\n<p>t.circle(100)<\/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\u4e0a\u8ff0\u4ee3\u7801\u4e2d\uff0c\u6211\u4eec\u521b\u5efa\u4e86\u4e00\u4e2aTurtle\u5bf9\u8c61\uff0c\u5e76\u901a\u8fc7\u8c03\u7528<code>circle<\/code>\u51fd\u6570\u7ed8\u5236\u4e86\u4e00\u4e2a\u534a\u5f84\u4e3a100\u7684\u5706\u5f62\u3002<\/p>\n<\/p>\n<ol start=\"3\">\n<li><strong>\u81ea\u5b9a\u4e49\u5706\u5f62\u7684\u5c5e\u6027<\/strong><\/li>\n<\/ol>\n<p><p>Turtle\u5e93\u5141\u8bb8\u81ea\u5b9a\u4e49\u5706\u5f62\u7684\u989c\u8272\u548c\u586b\u5145\u7b49\u5c5e\u6027\u3002\u53ef\u4ee5\u901a\u8fc7\u8bbe\u7f6eTurtle\u5bf9\u8c61\u7684\u5c5e\u6027\u6765\u5b9e\u73b0\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">t.color(&quot;red&quot;)  # \u8bbe\u7f6e\u989c\u8272<\/p>\n<p>t.fillcolor(&quot;yellow&quot;)  # \u8bbe\u7f6e\u586b\u5145\u989c\u8272<\/p>\n<p>t.begin_fill()  # \u5f00\u59cb\u586b\u5145<\/p>\n<p>t.circle(100)  # \u7ed8\u5236\u5706\u5f62<\/p>\n<p>t.end_fill()  # \u7ed3\u675f\u586b\u5145<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u4e0a\u8ff0\u4ee3\u7801\u4e2d\uff0c\u6211\u4eec\u8bbe\u7f6e\u4e86\u5706\u5f62\u7684\u989c\u8272\u4e3a\u7ea2\u8272\uff0c\u586b\u5145\u989c\u8272\u4e3a\u9ec4\u8272\uff0c\u5e76\u5728\u7ed8\u5236\u5706\u5f62\u65f6\u4f7f\u7528\u586b\u5145\u3002<\/p>\n<\/p>\n<p><p>\u4e09\u3001PYGAME\u7ed8\u5236\u5706\u5f62<\/p>\n<\/p>\n<p><p>Pygame\u662f\u4e00\u4e2a\u7528\u4e8e\u5f00\u53d1\u6e38\u620f\u7684\u5e93\uff0c\u5177\u6709\u4e30\u5bcc\u7684\u56fe\u5f62\u5904\u7406\u529f\u80fd\u3002\u4f7f\u7528Pygame\u7ed8\u5236\u5706\u5f62\u53ef\u4ee5\u5b9e\u73b0\u52a8\u6001\u548c\u4ea4\u4e92\u5f0f\u7684\u56fe\u5f62\u3002<\/p>\n<\/p>\n<ol>\n<li><strong>\u5b89\u88c5\u548c\u5bfc\u5165Pygame<\/strong><\/li>\n<\/ol>\n<p><p>\u5728\u4f7f\u7528Pygame\u4e4b\u524d\uff0c\u9996\u5148\u9700\u8981\u786e\u4fdd\u5df2\u5b89\u88c5\u8be5\u5e93\u3002\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u547d\u4ee4\u8fdb\u884c\u5b89\u88c5\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pip install pygame<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u53ef\u4ee5\u5728Python\u811a\u672c\u4e2d\u5bfc\u5165Pygame\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import pygame<\/p>\n<p><\/code><\/pre>\n<\/p>\n<ol start=\"2\">\n<li><strong>\u4f7f\u7528Pygame\u7ed8\u5236\u5706\u5f62<\/strong><\/li>\n<\/ol>\n<p><p>Pygame\u4e2d\u53ef\u4ee5\u4f7f\u7528<code>draw.circle<\/code>\u51fd\u6570\u7ed8\u5236\u5706\u5f62\u3002\u4e0b\u9762\u662f\u4e00\u4e2a\u7b80\u5355\u7684\u793a\u4f8b\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import pygame<\/p>\n<p>import sys<\/p>\n<h2><strong>\u521d\u59cb\u5316Pygame<\/strong><\/h2>\n<p>pygame.init()<\/p>\n<h2><strong>\u8bbe\u7f6e\u5c4f\u5e55\u5927\u5c0f<\/strong><\/h2>\n<p>screen = pygame.display.set_mode((400, 300))<\/p>\n<h2><strong>\u8bbe\u7f6e\u989c\u8272<\/strong><\/h2>\n<p>blue = (0, 0, 255)<\/p>\n<h2><strong>\u8fd0\u884c\u6e38\u620f\u5faa\u73af<\/strong><\/h2>\n<p>running = True<\/p>\n<p>while running:<\/p>\n<p>    for event in pygame.event.get():<\/p>\n<p>        if event.type == pygame.QUIT:<\/p>\n<p>            running = False<\/p>\n<p>    # \u586b\u5145\u5c4f\u5e55\u80cc\u666f<\/p>\n<p>    screen.fill((255, 255, 255))<\/p>\n<p>    # \u7ed8\u5236\u5706\u5f62<\/p>\n<p>    pygame.draw.circle(screen, blue, (200, 150), 100)<\/p>\n<p>    # \u66f4\u65b0\u663e\u793a<\/p>\n<p>    pygame.display.flip()<\/p>\n<h2><strong>\u9000\u51faPygame<\/strong><\/h2>\n<p>pygame.quit()<\/p>\n<p>sys.exit()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u4e0a\u8ff0\u4ee3\u7801\u4e2d\uff0c\u6211\u4eec\u521b\u5efa\u4e86\u4e00\u4e2a400&#215;300\u7684\u7a97\u53e3\uff0c\u5e76\u5728\u6e38\u620f\u5faa\u73af\u4e2d\u4f7f\u7528<code>draw.circle<\/code>\u51fd\u6570\u7ed8\u5236\u4e86\u4e00\u4e2a\u5706\u5fc3\u4f4d\u4e8e(200, 150)\uff0c\u534a\u5f84\u4e3a100\u7684\u84dd\u8272\u5706\u5f62\u3002<\/p>\n<\/p>\n<ol start=\"3\">\n<li><strong>\u81ea\u5b9a\u4e49\u5706\u5f62\u7684\u5c5e\u6027<\/strong><\/li>\n<\/ol>\n<p><p>Pygame\u5141\u8bb8\u81ea\u5b9a\u4e49\u5706\u5f62\u7684\u989c\u8272\u548c\u4f4d\u7f6e\u7b49\u5c5e\u6027\uff0c\u53ef\u4ee5\u901a\u8fc7<code>draw.circle<\/code>\u51fd\u6570\u7684\u53c2\u6570\u8fdb\u884c\u8bbe\u7f6e\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">pygame.draw.circle(screen, (255, 0, 0), (100, 100), 50, 5)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u4e0a\u8ff0\u4ee3\u7801\u4e2d\uff0c\u6211\u4eec\u8bbe\u7f6e\u4e86\u5706\u5f62\u7684\u989c\u8272\u4e3a\u7ea2\u8272\uff0c\u5706\u5fc3\u4e3a(100, 100)\uff0c\u534a\u5f84\u4e3a50\uff0c\u8fb9\u6846\u5bbd\u5ea6\u4e3a5\u3002<\/p>\n<\/p>\n<p><p>\u901a\u8fc7\u4ee5\u4e0a\u51e0\u79cd\u65b9\u6cd5\uff0c\u6211\u4eec\u53ef\u4ee5\u5728Python\u4e2d\u8f7b\u677e\u7ed8\u5236\u51fa\u5404\u79cd\u6837\u5f0f\u7684\u5706\u5f62\u3002\u6bcf\u79cd\u65b9\u6cd5\u90fd\u6709\u5176\u72ec\u7279\u7684\u4f18\u52bf\u548c\u9002\u7528\u573a\u666f\uff0c\u53ef\u4ee5\u6839\u636e\u5177\u4f53\u9700\u6c42\u9009\u62e9\u5408\u9002\u7684\u5e93\u548c\u5de5\u5177\u8fdb\u884c\u7ed8\u56fe\u3002\u5728\u5b66\u4e60\u548c\u5b9e\u8df5\u8fc7\u7a0b\u4e2d\uff0c\u7406\u89e3\u8fd9\u4e9b\u5e93\u7684\u57fa\u672c\u6982\u5ff5\u548c\u64cd\u4f5c\u6b65\u9aa4\uff0c\u5c06\u6709\u52a9\u4e8e\u66f4\u597d\u5730\u5e94\u7528Python\u8fdb\u884c\u6570\u636e\u53ef\u89c6\u5316\u548c\u56fe\u5f62\u5904\u7406\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u5982\u4f55\u5728Python\u4e2d\u7ed8\u5236\u4e00\u4e2a\u7b80\u5355\u7684\u5706\uff1f<\/strong><br \/>\u53ef\u4ee5\u4f7f\u7528Python\u4e2d\u7684<code>matplotlib<\/code>\u5e93\u6765\u7ed8\u5236\u7b80\u5355\u7684\u5706\u3002\u9996\u5148\uff0c\u9700\u8981\u5b89\u88c5\u8fd9\u4e2a\u5e93\uff0c\u4f7f\u7528<code>pip install matplotlib<\/code>\u547d\u4ee4\u3002\u63a5\u7740\uff0c\u60a8\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u4ee3\u7801\u6765\u7ed8\u5236\u4e00\u4e2a\u5706\u5f62\uff1a<\/p>\n<pre><code class=\"language-python\">import matplotlib.pyplot as plt\n\n# \u521b\u5efa\u4e00\u4e2a\u56fe\u5f62\u548c\u5750\u6807\u8f74\nfig, ax = plt.subplots()\n\n# \u6dfb\u52a0\u4e00\u4e2a\u5706\u5f62\uff0c\u4e2d\u5fc3\u4e3a(0, 0)\uff0c\u534a\u5f84\u4e3a1\ncircle = plt.Circle((0, 0), 1, color=&#39;blue&#39;, fill=False)\n\n# \u5c06\u5706\u5f62\u6dfb\u52a0\u5230\u5750\u6807\u8f74\u4e2d\nax.add_artist(circle)\n\n# \u8bbe\u7f6e\u5750\u6807\u8f74\u7684\u8303\u56f4\nax.set_xlim(-1.5, 1.5)\nax.set_ylim(-1.5, 1.5)\n\n# \u8bbe\u7f6e\u76f8\u7b49\u7684\u6bd4\u4f8b\nax.set_aspect(&#39;equal&#39;, adjustable=&#39;box&#39;)\n\n# \u663e\u793a\u56fe\u5f62\nplt.show()\n<\/code><\/pre>\n<p><strong>\u53ef\u4ee5\u4f7f\u7528\u54ea\u4e9b\u5e93\u6765\u7ed8\u5236\u5706\u5f62\uff1f<\/strong><br \/>\u9664\u4e86<code>matplotlib<\/code>\uff0cPython\u8fd8\u6709\u5176\u4ed6\u51e0\u4e2a\u5e93\u53ef\u4ee5\u7528\u4e8e\u7ed8\u5236\u5706\u5f62\u3002\u4f8b\u5982\uff0c<code>turtle<\/code>\u5e93\u975e\u5e38\u9002\u5408\u521d\u5b66\u8005\uff0c\u5b83\u63d0\u4f9b\u4e86\u7b80\u5355\u7684\u56fe\u5f62\u7ed8\u5236\u529f\u80fd\u3002\u60a8\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u4ee3\u7801\u521b\u5efa\u4e00\u4e2a\u5706\uff1a<\/p>\n<pre><code class=\"language-python\">import turtle\n\n# \u521b\u5efa\u4e00\u4e2a\u753b\u5e03\nt = turtle.Turtle()\n\n# \u753b\u4e00\u4e2a\u534a\u5f84\u4e3a100\u7684\u5706\nt.circle(100)\n\n# \u5b8c\u6210\u7ed8\u5236\nturtle.done()\n<\/code><\/pre>\n<p><strong>\u5728\u7ed8\u5236\u5706\u65f6\u5982\u4f55\u81ea\u5b9a\u4e49\u5706\u7684\u989c\u8272\u548c\u586b\u5145\uff1f<\/strong><br \/>\u5728<code>matplotlib<\/code>\u4e2d\uff0c\u53ef\u4ee5\u901a\u8fc7\u53c2\u6570\u8bbe\u7f6e\u5706\u7684\u989c\u8272\u548c\u586b\u5145\u72b6\u6001\u3002\u4f8b\u5982\uff0c\u60a8\u53ef\u4ee5\u5728\u521b\u5efa\u5706\u5f62\u65f6\u6dfb\u52a0<code>color<\/code>\u548c<code>fill<\/code>\u53c2\u6570\uff1a<\/p>\n<pre><code class=\"language-python\">circle = plt.Circle((0, 0), 1, color=&#39;red&#39;, fill=True)\n<\/code><\/pre>\n<p>\u5728<code>turtle<\/code>\u5e93\u4e2d\uff0c\u53ef\u4ee5\u4f7f\u7528<code>fillcolor<\/code>\u548c<code>begin_fill<\/code>\u3001<code>end_fill<\/code>\u51fd\u6570\u6765\u8bbe\u7f6e\u989c\u8272\u548c\u586b\u5145\uff1a<\/p>\n<pre><code class=\"language-python\">import turtle\n\nt = turtle.Turtle()\nt.fillcolor(&quot;green&quot;)  # \u8bbe\u7f6e\u586b\u5145\u989c\u8272\nt.begin_fill()        # \u5f00\u59cb\u586b\u5145\nt.circle(100)         # \u753b\u5706\nt.end_fill()          # \u7ed3\u675f\u586b\u5145\nturtle.done()\n<\/code><\/pre>\n<p>\u901a\u8fc7\u8fd9\u4e9b\u65b9\u6cd5\uff0c\u60a8\u53ef\u4ee5\u7075\u6d3b\u5730\u7ed8\u5236\u51fa\u4e0d\u540c\u6837\u5f0f\u7684\u5706\u5f62\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u5728Python\u4e2d\uff0c\u53ef\u4ee5\u4f7f\u7528\u591a\u79cd\u65b9\u6cd5\u6765\u7ed8\u5236\u5706\u5f62\uff0c\u4e3b\u8981\u53d6\u51b3\u4e8e\u6240\u9009\u62e9\u7684\u5e93\u548c\u5de5\u5177\u3002\u4f7f\u7528Python\u7ed8\u5236\u5706\u5f62\u7684\u5e38\u7528\u65b9\u6cd5\u5305 [&hellip;]","protected":false},"author":3,"featured_media":1011510,"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\/1011503"}],"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=1011503"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1011503\/revisions"}],"predecessor-version":[{"id":1011511,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1011503\/revisions\/1011511"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/1011510"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=1011503"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=1011503"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=1011503"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}